cbcbbb2fbe (master): Let Ractor::IsolationError report correct constant path

0 views
Skip to first unread message

Daisuke Aritomo

unread,
Dec 16, 2025, 8:16:26 PM (6 hours ago) Dec 16
to ruby...@g.ruby-lang.org
Daisuke Aritomo 2025-12-15 09:04:57 +0000 (Mon, 15 Dec 2025)

New Revision: cbcbbb2fbe

https://github.com/ruby/ruby/commit/cbcbbb2fbe

Log:
Let Ractor::IsolationError report correct constant path

Before this patch, Ractor::IsolationError reported an incorrect constant
path when constant was found through `rb_const_get_0()`.

In this code, Ractor::IsolationError reported illegal access against
`M::TOPLEVEL`, where it should be `Object::TOPLEVEL`.

```ruby
TOPLEVEL = [1]

module M
def self.f
TOPLEVEL
end
end

Ractor.new { M.f }.value
```

This was because `rb_const_get_0()` built the "path" part referring to
the module/class passed to it in the first place. When a constant was
found through recursive search upwards, the module/class which the
constant was found should be reported.

This patch fixes this issue by modifying rb_const_search() to take a
VALUE pointer to be filled with the module/class where the constant was
found.

[Bug #21782]

Modified files:
bootstraptest/test_ractor.rb
variable.c
Reply all
Reply to author
Forward
0 new messages