Forum: Ruby-Gnome 2 Re: Crash when handling exception coming from an signal hand

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
01cd8e7814352de3c59dd5e5ec95f798?d=identicon&s=25 Masao Mutoh (Guest)
on 2006-05-16 14:02
(Received via mailing list)
I re-send this mail because sometimes my e-mail server rejected by
sf.net.

-----
Hi,

Hmm, it doesn't occur on my system.

% ruby test.rb
test.rb:10: undefined method `bloep!' for main:Object (NoMethodError)
       from test.rb:20
% ruby -v
ruby 1.8.4 (2005-12-24) [i686-linux]

Ruby-GNOME2 is latest CVS version,
with your rbgclosure patch.

Tell me the detail of your system what this problem occures.

If it's on x86_64 system only,
I can't test it ... it may be a problem with incorrect casting anywhere.


On Fri, 12 May 2006 12:41:18 +0200
sjoerd@spring.luon.net (Sjoerd Simons) wrote:

>     ==10757==    by 0x5761382: g_signal_emit (in
>     ==10757==    by 0x4B5F8A1: ruby_run (in /usr/lib/libruby1.8.so.1.8.4)
> 	"It's today!" said Piglet.
> 	"My favorite day," said Pooh.
>


--
--
.:% Masao Mutoh<mutoh@highway.ne.jp>
6bf57b10a0d04acd62b9d83a8a791327?d=identicon&s=25 unknown (Guest)
on 2006-05-16 19:51
(Received via mailing list)
On Mon, May 15, 2006 at 12:22:17AM +0900, Masao Mutoh wrote:
> % ruby -v
> ruby 1.8.4 (2005-12-24) [i686-linux]
>
> Ruby-GNOME2 is latest CVS version,
> with your rbgclosure patch.
>
> Tell me the detail of your system what this problem occures.
>
> If it's on x86_64 system only,
> I can't test it ... it may be a problem with incorrect casting anywhere.

I can reproduce it both on amd64 and on x86 (the one shown above was on
a
x86). I've got glib 2.10.2, which might also has something to do with
it?

  Sjoerd
--
The questions remain the same.  The answers are eternally variable.


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709...
1ba7514948bfec30a29598426c060963?d=identicon&s=25 Mathieu Blondel (Guest)
on 2006-05-16 22:29
(Received via mailing list)
Hi,
>
> I can reproduce it both on amd64 and on x86 (the one shown above was on a
> x86). I've got glib 2.10.2, which might also has something to do with it?
>
>   Sjoerd
>
I've run your test program ang got the same error as you. Then I
dist-upgraded my system (I'm running unstable) and now the exception is
caught as expected (same message as Masao).

Since glib has not been updated meanwhile, I think the problem comes
from gtk : the new version on my system is now 2.8.17-1.

HTH

--
Mathieu Blondel
http://www.mblondel.org



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709...
6bf57b10a0d04acd62b9d83a8a791327?d=identicon&s=25 unknown (Guest)
on 2006-05-17 01:30
(Received via mailing list)
On Tue, May 16, 2006 at 10:23:10PM +0200, Mathieu Blondel wrote:
>
> Since glib has not been updated meanwhile, I think the problem comes
> from gtk : the new version on my system is now 2.8.17-1.

I'm also running the latest debian unstable on my machines. Could you do
me a
favour. Please install libglib2.0-0-dbg and run my test program under
valgrind.

Just skip all the initial output.. Wait till it's fully rendered, if you
then
can move the slider without any valgrind output it does indeed not occur
at all
on your machine. Otherwise it happens, but just doesn't cause a crash :)

I've attached the relevant part of my valgrind log, so if you want you
can
check for differences if you get any output...

  Sjoerd
6bf57b10a0d04acd62b9d83a8a791327?d=identicon&s=25 unknown (Guest)
on 2006-05-17 11:49
(Received via mailing list)
On Mon, May 15, 2006 at 12:22:17AM +0900, Masao Mutoh wrote:
> % ruby -v
> ruby 1.8.4 (2005-12-24) [i686-linux]
>
> Ruby-GNOME2 is latest CVS version,
> with your rbgclosure patch.
>
> Tell me the detail of your system what this problem occures.
>
> If it's on x86_64 system only,
> I can't test it ... it may be a problem with incorrect casting anywhere.

Ok, i've investigated this further. Glib signals are not written to
handle
exception handling via setjmp/longjmp or getcontext/getcontext over the
signal
code itself. So the current code can lead to interesting errors (like
the one
i encountered).

More specifically. When glib emits a signal it saves some pointer to
values on
the stack, then the handler is run. Now if we get an exception in the
handler
it will do JUMP_TAG, which jumps out of the signal code and eventually
causes
a part of the stack to be invalidated.  But glib's signal code still has
a
pointer to something on that part of the stack! So when the next glib
signal is
handled it will dereference to someting that's no longer there... Which
is what
causes the crash i'm seeing on some machines, but if your lucky you
don't
even notice it except when running valgrind (which is what i see on some
other
machines).

The only solution to this afaik is to not propagate the exception over
the
signal handling boundry. Which is exactly what for example the python
gtk
bindings do.

Attached patch does that. It just prints the relevant part of the
exception and
instead of propagating it.

  Sjoerd
1ba7514948bfec30a29598426c060963?d=identicon&s=25 Mathieu Blondel (Guest)
on 2006-05-17 12:02
(Received via mailing list)
Hi,
> I'm also running the latest debian unstable on my machines. Could you do me a
> favour. Please install libglib2.0-0-dbg and run my test program under valgrind.
I don't have time right now to compare my log with yours.

HTH,
9fe908f5593444a40be14a424c372e58?d=identicon&s=25 Masao Mutoh (Guest)
on 2006-05-17 14:45
(Received via mailing list)
Hi Sjoerd,

On Wed, 17 May 2006 11:47:06 +0200
sjoerd@spring.luon.net (Sjoerd Simons) wrote:

> Ok, i've investigated this further. Glib signals are not written to handle
> exception handling via setjmp/longjmp or getcontext/getcontext over the signal
> code itself. So the current code can lead to interesting errors (like the one
> i encountered).

<snip>

> The only solution to this afaik is to not propagate the exception over the
> signal handling boundry. Which is exactly what for example the python gtk
> bindings do.
>
> Attached patch does that. It just prints the relevant part of the exception and
> instead of propagating it.

OK. Applied. Thanks for your investigation and
explanation in detail. I could understand it well ;).

BTW, I'm waiting 2 your reply.

Could you reply them ?
I've not apply these patch yet.

http://www.ruby-forum.com/topic/65877#new
http://www.ruby-forum.com/topic/61419#new

--
.:% Masao Mutoh<mutoh@highway.ne.jp>


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709...
6bf57b10a0d04acd62b9d83a8a791327?d=identicon&s=25 unknown (Guest)
on 2006-05-17 15:46
(Received via mailing list)
On Wed, May 17, 2006 at 09:41:29PM +0900, Masao Mutoh wrote:
> <snip>
>
> > The only solution to this afaik is to not propagate the exception over the
> > signal handling boundry. Which is exactly what for example the python gtk
> > bindings do.
> >
> > Attached patch does that. It just prints the relevant part of the exception and
> > instead of propagating it.
>
> OK. Applied. Thanks for your investigation and
> explanation in detail. I could understand it well ;).

Thanks !

> BTW, I'm waiting 2 your reply.
>
> Could you reply them ?
> I've not apply these patch yet.
>
> http://www.ruby-forum.com/topic/65877#new
> http://www.ruby-forum.com/topic/61419#new

I've replied on one of them (about value array), didn't know you were
waiting
for an answer.

For the glib thread signal problem, now i CVS works again i need some
time to
resync my stuff and i'll send you a new patch with some debug info rsn.

  Sjoerd
--
UFOs are for real: the Air Force doesn't exist.


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709...
This topic is locked and can not be replied to.