Project

General

Profile

Bug #11667

Ruby process crashes when TracePoint.new(:raise) is enabled and SystemStackError is raised

Added by yuki24 (Yuki Nishijima) over 3 years ago. Updated 7 months ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-10-23 trunk 52247) [x86_64-linux]
[ruby-core:71388]

Description

Let's say a TracePoint.new(:raise) is enabled. When a method that recursively calls itself, the Ruby process will just die rather than raising a SystemStackError.

$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
$ irb
2.2.3 :001 > TracePoint.new(:raise){}.enable
 => false 
2.2.3 :002 > def f(i); f(i-1); end; f(10_000)
/usr/local/rvm/rubies/ruby-2.2.3/bin/irb: exception reentered (fatal)
$ ruby -v
ruby 2.3.0dev (2015-10-23 trunk 52247) [x86_64-linux]
$ irb
head :001 > TracePoint.new(:raise){|tp| tp.raised_exception }.enable
 => false 
head :002 > def f(i); f(i-1); end; f(10_000)
/usr/local/rvm/rubies/ruby-head/bin/irb: exception reentered (fatal)

I expect this code to raise SystemStackError instead.

History

Updated by tleish (Tony Fenleish) 7 months ago

We recently ran into this same problem in Ruby 2.4.x, however this appears to be fixed in Ruby 2.5.

In the command below you should see an exception in the output, but instead the application crashes with no output.

$ ruby -v 
ruby 2.4.4p296 (2018-03-28 revision 63013) [x86_64-darwin17]
$ ruby -e 'TracePoint.new(:raise){}.enable; def f(i); f(i-1); end; f(10_000)'
$

With ruby 5.1, we now see the SystemStackError

$ ruby -v 
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
$ ruby -e 'TracePoint.new(:raise){}.enable; def f(i); f(i-1); end; f(10_000)'
Traceback (most recent call last):
    11913: from -e:1:in `<main>'
    11912: from -e:1:in `f'
    11911: from -e:1:in `f'
    11910: from -e:1:in `f'
    11909: from -e:1:in `f'
    11908: from -e:1:in `f'
    11907: from -e:1:in `f'
    11906: from -e:1:in `f'
     ... 11901 levels...
        4: from -e:1:in `f'
        3: from -e:1:in `f'
        2: from -e:1:in `f'
        1: from -e:1:in `f'
-e:1:in `f': stack level too deep (SystemStackError)

Also available in: Atom PDF