# Crash when handling exception coming from an signal handler

**URL:** <https://www.ruby-forum.com/t/crash-when-handling-exception-coming-from-an-signal-handler/94846>\
**Category:** Ruby-Gnome 2\
**Created:** [May 16, 2006, 3:08pm UTC](https://www.ruby-forum.com/t/crash-when-handling-exception-coming-from-an-signal-handler/94846 "2006-05-16T15:08:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 16, 2006, 3:08pm UTC](https://www.ruby-forum.com/t/crash-when-handling-exception-coming-from-an-signal-handler/94846/1 "2006-05-16T15:08:20Z")

</div>

Hi,

I got some strange crashes when handling an exception coming from a  
signal  
handler. I was able to make a contrived example that triggers it  
reliably  
(on _some_ of my systems) ☹

valgrind shows the following:  
==10757== Invalid read of size 8  
==10757== at 0x5760FA0: g\_signal\_emit\_valist (in  
/usr/lib/libgobject-2.0.so.0.1000.2)  
==10757== by 0x5761382: g\_signal\_emit (in  
/usr/lib/libgobject-2.0.so.0.1000.2)  
==10757== by 0x791E41B: gtk\_adjustment\_value\_changed (in  
/usr/lib/libgtk-x11-2.0.so.0.800.17)  
==10757== by 0x7729936: (within  
/usr/lib/ruby/1.8/x86\_64-linux/gtk2.so)  
==10757== by 0x4B530EB: (within /usr/lib/libruby1.8.so.1.8.4)  
==10757== by 0x4B53540: (within /usr/lib/libruby1.8.so.1.8.4)  
==10757== by 0x4B4F1F5: (within /usr/lib/libruby1.8.so.1.8.4)  
==10757== by 0x4B51106: (within /usr/lib/libruby1.8.so.1.8.4)  
==10757== by 0x4B5D5BA: (within /usr/lib/libruby1.8.so.1.8.4)  
==10757== by 0x4B5D604: ruby\_exec (in  
/usr/lib/libruby1.8.so.1.8.4)  
==10757== by 0x4B5F8A1: ruby\_run (in  
/usr/lib/libruby1.8.so.1.8.4)  
==10757== by 0x4007B8: main (in /usr/bin/ruby1.8)  
==10757== Address 0x7FEFFD438 is not stack’d, malloc’d or  
(recently) free’d

I digged somewhat deeper and it appears that the g\_restart\_emissions  
in  
glib2’s gsignal.c points to some memory that’s no longer on the  
stack :(… Probably because of some strange interaction between glib’s  
signal  
handling and ruby jumping to another (exception handling) context…

Sjoerd

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [May 16, 2006, 5:07pm UTC](https://www.ruby-forum.com/t/crash-when-handling-exception-coming-from-an-signal-handler/94846/2 "2006-05-16T17:07:43Z")

</div>

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  
removed\_email\_address@domain.invalid (Sjoerd S.) 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 M.[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

* * *

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&bid=263057&dat=121642](http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642)
