diff options
author | John Hawthorn <john@hawthorn.email> | 2019-11-07 14:50:05 -0800 |
---|---|---|
committer | Aaron Patterson <tenderlove@github.com> | 2019-11-08 12:41:05 -0800 |
commit | 3b6954f8b9189f599e1f17636f8667a95ee94193 (patch) | |
tree | 219cedfe41e47690e474922d166c64ab8e2b2550 /test/ruby/test_gc.rb | |
parent | 9deca1a3b91271159e164188367f003978737f42 (diff) |
Fix passing actual object_id to finalizer
Previously we were passing the memory_id. This was broken previously if
compaction was run (which changes the memory_id) and now that object_id
is a monotonically increasing number it was always broken.
This commit fixes this by defering removal from the object_id table
until finalizers have run (for objects with finalizers) and also copying
the SEEN_OBJ_ID flag onto the zombie objects.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2658
Diffstat (limited to 'test/ruby/test_gc.rb')
-rw-r--r-- | test/ruby/test_gc.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index f42e098863..ef99f69f50 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -372,6 +372,14 @@ class TestGc < Test::Unit::TestCase assert_empty(out) end + def test_finalizer_passed_object_id + assert_in_out_err(%w[--disable-gems], <<-EOS, ["true"], []) + o = Object.new + obj_id = o.object_id + ObjectSpace.define_finalizer(o, ->(id){ p id == obj_id }) + EOS + end + def test_verify_internal_consistency assert_nil(GC.verify_internal_consistency) end |