diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2021-07-08 18:23:39 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2022-06-22 08:30:39 -0400 |
commit | 744d17ff6c33b09334508e8110007ea2a82252f5 (patch) | |
tree | 38579b596f6d2fea31a85864f75ce3d874968cbf /test/ruby/test_settracefunc.rb | |
parent | e6f92cada1cf8026d0dc6dbd11867ba9a994f4d6 (diff) |
Fix infinite loop when b_return TracePoint throws
Previously, we didn't pop the frame that runs the TracePoint hook for
b_return events for blocks running as methods (bmethods). In case the
hook raises, that formed an infinite loop during stack unwinding in
hook_before_rewind().
[Bug #18060]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4638
Diffstat (limited to 'test/ruby/test_settracefunc.rb')
-rw-r--r-- | test/ruby/test_settracefunc.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index bbd7579eeb..56d457c7d7 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -2656,4 +2656,31 @@ CODE TracePoint.allow_reentry{} end end + + def test_raising_from_b_return_tp_tracing_bmethod + assert_normal_exit(<<~RUBY, '[Bug #18060]', timeout: 3) + class Foo + define_singleton_method(:foo) { return } # a bmethod + end + + TracePoint.trace(:b_return) do |tp| + raise + end + + Foo.foo + RUBY + + # Same thing but with a target + assert_normal_exit(<<~RUBY, '[Bug #18060]', timeout: 3) + class Foo + define_singleton_method(:foo) { return } # a bmethod + end + + TracePoint.new(:b_return) do |tp| + raise + end.enable(target: Foo.method(:foo)) + + Foo.foo + RUBY + end end |