Moin!
In Ruby 1.8.0 old SystemStackErrors seem to be reused when
there should have been raised a new one instead:
irb(main):001:0> y = proc { y.call }; y.call rescue nil
=> nil
irb(main):002:0> eval 'z = proc { z.call }; z.call'
SystemStackError: (irb):1:in `irb_binding': stack level too deep
This can cause serious problems when you're running multiple Threads
with different levels of safeness, because of fatal exceptions. This
code snippet:
2.times {
begin
Thread.new {
$SAFE = 4 # error isn't caused on lower $SAFE levels
r = proc { r.call }; r.call # create a SystemStackError
}.value
rescue Exception => error; end
p error
}
produces this output for me:
nil
#<fatal: exception reentered>
I'm using ruby 1.8.0 (2003-08-04) [i386-mswin32] and the errors also
occur with linux releases of ruby 1.8.0.
I haven't been able to run the above test code on an 1.6.8 release yet,
so the bug might have been introduced only recently.
That fatal exception is a show stopper for me because my application is
instantly killed by it and because weirdly I'm not able to rescue it in
the context where it happens.
Regards,
Florian Gross