diff options
| author | John Hawthorn <john@hawthorn.email> | 2023-10-11 11:09:04 -0700 |
|---|---|---|
| committer | John Hawthorn <john@hawthorn.email> | 2023-10-12 10:22:32 +0200 |
| commit | 635b92099e7ddd1b2eca065134efcfdc7ad7bab3 (patch) | |
| tree | 26e6e71bb8a60ec8beb7c8c36d71ec47e1ca9d87 /test | |
| parent | 9859dbc7fdaef2073fecd062c7294ab4dbb86b27 (diff) | |
Fix ObjectSpace.dump with super() callinfo
super() uses 0 as mid for its callinfo, so we need to check for that to
avoid a segfault when using dump_all.
Diffstat (limited to 'test')
| -rw-r--r-- | test/objspace/test_objspace.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index 43ccac7920..bc6799b49f 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -562,6 +562,27 @@ class TestObjSpace < Test::Unit::TestCase end end + def test_dump_callinfo_includes_mid + assert_in_out_err(%w[-robjspace], "#{<<-"begin;"}\n#{<<-'end;'}") do |output, error| + begin; + class Foo + def foo + super(bar: 123) # should not crash on 0 mid + end + + def bar + baz(bar: 123) # mid: baz + end + end + + ObjectSpace.dump_all(output: $stdout) + end; + assert_empty error + assert(output.count > 1) + assert_equal 1, output.count { |l| l.include?('"mid":"baz"') } + end + end + def test_dump_string_coderange assert_includes ObjectSpace.dump("TEST STRING"), '"coderange":"7bit"' unknown = "TEST STRING".dup.force_encoding(Encoding::BINARY) |
