Fix missing write barriers of imemo_fields in Ractor copy/move traversal by jhawthorn · Pull Request #13783 · ruby/ruby · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Fix missing write barriers of imemo_fields in Ractor copy/move traversal #13783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jhawthorn
Copy link
Member

Found by wbcheck. This fixes two cases where write barriers could be missed when Ractor copying/moving objects with generic fields.

  • When we move a geniv object, the new object needs a write barrier because it gains a reference to the fields. (incremental GC could happen as during inserting the new key into the table)
  • When we're copying a geniv object, the write barrier needs to come from the fields object rather than the object itself.

cc @byroot

jhawthorn added 2 commits July 2, 2025 23:45
    $ RUBY_GC_LIBRARY=wbcheck ./miniruby -e 's = String.new; s.instance_variable_set(:@x, []); Ractor.make_shareable(s, copy: true)'

    WBCHECK ERROR: Missed write barrier detected!
      Parent object: 0x7ba8162dc890 (wb_protected: true)
        rb_obj_info_dump: 0x00007ba8162dc890 T_IMEMO/<fields>
      Reference counts - snapshot: 2, writebarrier: 0, current: 2, missed: 1
      Missing reference to: 0x7ba8162dcad0
        rb_obj_info_dump: 0x00007ba8162dcad0 T_ARRAY/Array [E ] len: 0 (embed)

    WBCHECK SUMMARY: Found 1 objects with missed write barriers (1 total violations)
When moving a "generic IV" object, we need a write barrier to the fields
object.

   WBCHECK ERROR: Missed write barrier detected!
     Parent object: 0x7c913641d1a0 (wb_protected: true)
       rb_obj_info_dump: 0x00007c913641d1a0 T_ARRAY/Array [E ] len: 10 (embed)
     Reference counts - snapshot: 1, writebarrier: 0, current: 2, missed: 1
     Missing reference to: 0x7bf1364e56d0
       rb_obj_info_dump: 0x00007bf1364e56d0 T_IMEMO/<fields>
@@ -1681,7 +1681,7 @@ obj_traverse_replace_i(VALUE obj, struct obj_traverse_replace_data *data)
uint32_t fields_count = RSHAPE_LEN(RBASIC_SHAPE_ID(obj));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like up here I need to also make a change so that the complex fields also have the correct write barrier, but I want to make a test first that surfaces that to wbcheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.