Issue #11668 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Closed

It looks like this problem was fixed.  While I can get this code to segfaul=
t on Ruby <2.5, I can no longer get a segfault for this code starting with =
Ruby 2.5:

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

  alias_method :to_default_s, :to_s
end

TracePoint.trace(:return) { |_tp| }
1.to_s
```

----------------------------------------
Bug #11668: SEGV instead of SystemStackError when using the TracePoint API
https://bugs.ruby-lang.org/issues/11668#change-82212

* Author: deivid (David Rodr=EDguez)
* Status: Closed
* Priority: Normal
* Assignee: =

* Target version: =

* ruby -v: ruby 2.3.0dev (2015-11-09 trunk 52499) [x86_64-linux
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
**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 (Syst=
emStackError)
   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=F3n de segmento
~~~



-- =

https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>