Actions
Bug #22440
closedReferencing an autoload constant from multiple Ractors dumps core
Bug #22440:
Referencing an autoload constant from multiple Ractors dumps core
Description
Referencing an autoload constant from multiple Ractors in parallel may cause a SEGV:
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 ofrb_vm_opt_getconstant_path, and reuses it within the function. - When
vm_get_ev_const_chainblocks waiting for an autoload, the M:N thread scheduler may resume the thread on a different native thread. - After that,
GET_RACTOR()invm_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.
Actions