diff options
author | Peter Zhu <[email protected]> | 2025-05-26 14:11:51 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2025-05-26 15:04:00 -0400 |
commit | 386f87481632f1ba8de53fd94d314183034a4b06 (patch) | |
tree | b656748ac065857f6e5b5909c348d09bcac29628 /ractor.c | |
parent | 909a0daab696c7b9dc1d23d27500e1eecd93e470 (diff) |
Don't copy FL_PROMOTED to new object in Ractor move
We should not copy the FL_PROMOTED flag when we move an object in Ractor#send(move: true)
because the newly created object may not be old.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13442
Diffstat (limited to 'ractor.c')
-rw-r--r-- | ractor.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -3656,8 +3656,15 @@ move_enter(VALUE obj, struct obj_traverse_replace_data *data) static enum obj_traverse_iterator_result move_leave(VALUE obj, struct obj_traverse_replace_data *data) { - size_t size = rb_gc_obj_slot_size(obj); - memcpy((void *)data->replacement, (void *)obj, size); + // Copy flags + VALUE ignored_flags = RUBY_FL_PROMOTED; + RBASIC(data->replacement)->flags = (RBASIC(obj)->flags & ~ignored_flags) | (RBASIC(data->replacement)->flags & ignored_flags); + // Copy contents without the flags + memcpy( + (char *)data->replacement + sizeof(VALUE), + (char *)obj + sizeof(VALUE), + rb_gc_obj_slot_size(obj) - sizeof(VALUE) + ); void rb_replace_generic_ivar(VALUE clone, VALUE obj); // variable.c |