From: "mame (Yusuke Endoh) via ruby-core" Date: 2026-10-14T19:05:56+00:00 Subject: [ruby-core:127108] [Ruby Bug#22440] Referencing an autoload constant from multiple Ractors dumps core Issue #22440 has been reported by mame (Yusuke Endoh). ---------------------------------------- Bug #22440: Referencing an autoload constant from multiple Ractors dumps core https://bugs.ruby-lang.org/issues/22440 * Author: mame (Yusuke Endoh) * Status: Assigned * Assignee: ko1 (Koichi Sasada) * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- Referencing an autoload constant from multiple Ractors in parallel may cause a SEGV: ```ruby # foo.rb module Foo; end ``` ```ruby # repro.rb autoload :Foo, "./foo" p 8.times.map { Ractor.new { Foo } }.map(&:value) ``` ``` $ ruby repro.rb repro.rb:2: [BUG] Segmentation fault at 0x0000000000000030 ``` Reproduced with GCC 16 on Ubuntu 26.04. Not reproduced with GCC 13 / 15. Cause: * GCC 16 computes the address of the TLS variable (`ruby_current_ec`) at the entry of `rb_vm_opt_getconstant_path`, and reuses it within the function. * When `vm_get_ev_const_chain` blocks waiting for an autoload, the M:N thread scheduler may resume the thread on a different native thread. * After that, `GET_RACTOR()` in `vm_ic_update` (inlined) reads the TLS of the previous native thread, refers to an invalid value, and SEGVs. Proposed fix: pass `ec` (already an argument of `rb_vm_opt_getconstant_path`) to `vm_ic_update`, and use `rb_ec_ractor_ptr(ec)` instead of `GET_RACTOR()`. https://github.com/ruby/ruby/pull/19348 Note: the SEGV in #22439 is this issue, triggered by the autoload of `Ruby::Prism`. Since #22439 also involves another problem, I created this ticket dedicated to the autoload + Ractor issue. -- 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/