From 054f56fd3e5bf84e5443896fd1f4e439c2773c60 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Wed, 20 Dec 2023 03:45:41 +0900 Subject: [PATCH] moved object should not have a shape ID fix [Bug #19917] --- bootstraptest/test_ractor.rb | 18 ++++++++++++++++++ ractor.c | 2 ++ 2 files changed, 20 insertions(+) diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb index 36ccc005dc..4383795dc1 100644 --- a/bootstraptest/test_ractor.rb +++ b/bootstraptest/test_ractor.rb @@ -1643,6 +1643,24 @@ assert_match /\Atest_ractor\.rb:1:\s+warning:\s+Ractor is experimental/, %q{ eval("Ractor.new{}.take", nil, "test_ractor.rb", 1) } +# check moved object +assert_equal 'ok', %q{ + r = Ractor.new do + Ractor.receive + GC.start + :ok + end + + obj = begin + raise + rescue => e + e = Marshal.load(Marshal.dump(e)) + end + + r.send obj, move: true + r.take +} + ## Ractor::Selector # Selector#empty? returns true diff --git a/ractor.c b/ractor.c index 8a7154ac27..8362f2f332 100644 --- a/ractor.c +++ b/ractor.c @@ -3491,6 +3491,8 @@ ractor_moved_bang(VALUE obj) rv->v3 = 0; rv->flags = rv->flags & ~fl_users; + if (BUILTIN_TYPE(obj) == T_OBJECT) ROBJECT_SET_SHAPE_ID(obj, ROOT_SHAPE_ID); + // TODO: record moved location }