Project

General

Profile

Actions

Bug #11668

closed

SEGV instead of SystemStackError when using the TracePoint API

Added by deivid (David Rodríguez) about 9 years ago. Updated about 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-11-09 trunk 52499) [x86_64-linux
[ruby-core:71389]

Description

fixnum_monkey.rb


class Fixnum
  define_method(:to_s) do |*args|
    to_default_s(*args)
  end

  alias_method :to_default_s, :to_s
end

If I use this code normally it gives me SystemStackError as expected

$ ruby -e "load('fixnum_monkey.rb');  5.to_s"
fixnum_monkey.rb:2:in `block in <class:Fixnum>': stack level too deep (SystemStackError)
   from fixnum_monkey.rb:3:in `block in <class:Fixnum>'
   from fixnum_monkey.rb:3:in `block in <class:Fixnum>'
   from fixnum_monkey.rb:3:in `block in <class:Fixnum>'
   from fixnum_monkey.rb:3:in `block in <class:Fixnum>'
   from fixnum_monkey.rb:3:in `block in <class:Fixnum>'
   from fixnum_monkey.rb:3:in `block in <class:Fixnum>'
   from fixnum_monkey.rb:3:in `block in <class:Fixnum>'
   from fixnum_monkey.rb:3:in `block in <class:Fixnum>'
    ... 5804 levels...
   from fixnum_monkey.rb:3:in `block in <class:Fixnum>'
   from fixnum_monkey.rb:3:in `block in <class:Fixnum>'
   from fixnum_monkey.rb:3:in `block in <class:Fixnum>'
   from -e:1:in `<main>'

But if I enable the return event of the TracePoint API before using it, I get a segfault

$ ruby -e "load('fixnum_monkey.rb'); TracePoint.trace(:return) { |_tp| }; 5.to_s"
Violación de segmento
Actions

Also available in: Atom PDF

Like0
Like0