[MacRuby-devel] TIL - Uncaught exceptions in threads cause SIGABRT in the main thread!

Laurent Sansonetti lsansonetti at apple.com
Mon Mar 14 13:14:37 PDT 2011


Hi Morgan,

Well in theory, you should NOT get a segfault when doing that.

When an exception isn't rescued inside a Thread, the correct behavior is that the thread will quit, and that the exception will be silently ignored. Then, once the Thread object is garbage collected, if the exception has not been retrieved from the Thread object (for instance, if #join has never been called on it), then a warning message is printed on stderr with the exception backtrace, for debugging purposes.

It would be nice if you could reproduce the segfault in a small test case, because it looks bad (we should never segfault) :)

Laurent

On Mar 13, 2011, at 6:31 PM, Morgan Schweers wrote:

> Greetings,
> Today I Learned :) if a thread throws an exception that isn't rescued by the top of the thread, it'll crash the app's main thread with 'Program received signal:  “SIGABRT”.'
> 
> That's been plaguing me since I started doing MacRuby development; every time I tried to start up multiple threads, the app became incredibly fragile and, unlike the main thread, it wouldn't show ruby traces.
> 
> Now I just wrap threads in begin/rescue blocks, and I'm all good.  Good programming practice anyway, but the failure mode is unobvious if you don't.
> 
> Hopefully this helps someone else!
> 
> --  Morgan
> 
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110314/a99a64ae/attachment.html>


More information about the MacRuby-devel mailing list