From: "himura467 (Akito Shitara) via ruby-core" Date: 2026-11-03T04:16:01+00:00 Subject: [ruby-core:127307] [Ruby Bug#22497] Reading a frozen Set held by another Ractor's class crashes Issue #22497 has been updated by himura467 (Akito Shitara). It was a duplicate of #22419 ---------------------------------------- Bug #22497: Reading a frozen Set held by another Ractor's class crashes https://bugs.ruby-lang.org/issues/22497#change-119731 * Author: himura467 (Akito Shitara) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ```ruby S = Set[].freeze Ractor.new { S }.join ``` ``` -e:1: [BUG] rb_objspace_reachable_objects_from_local: set is owned by another Ractor ``` Class variables and instance variables of classes crash the same way. Ruby 4.0.7 doesn't crash. ## Cause A Ractor that doesn't own the class checks whether `S` is shareable by traversing it. Since commit:git|f0439cdfa7 ([GH-19145](https://github.com/ruby/ruby/pull/19145)), the children of a T_DATA without declarative marking are enumerated with `rb_objspace_reachable_objects_from_local()`, which rejects an object owned by another Ractor. The commit before it doesn't crash. ## Question I'm still looking for a good fix. Here is what I've tried so far. Restoring the enumeration from before f0439cdfa7 for foreign objects (the VM-locked `rb_objspace_reachable_objects_from()`) fixes the crash, but passes that function an object its comment doesn't allow ("obj may be owned by another Ractor (a shareable)"). I also tried having the owner check shareability when assigning instead, but it doesn't seem to be enough: `lib/tmpdir.rb` freezes `Dir::Tmpname::RANDOM` after assigning it, which breaks `Tempfile` in non-main Ractors. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/