mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 04:24:23 +00:00
Add the class variable and the class itself in Ractor::IsolationError (#15562)
This commit is contained in:
parent
6b35f074bd
commit
09a29e1312
Notes:
git
2025-12-16 16:07:04 +00:00
Merged-By: luke-gru <luke.gru@gmail.com>
@ -1022,7 +1022,7 @@ assert_equal '1234', %q{
|
||||
}
|
||||
|
||||
# cvar in shareable-objects are not allowed to access from non-main Ractor
|
||||
assert_equal 'can not access class variables from non-main Ractors', %q{
|
||||
assert_equal 'can not access class variables from non-main Ractors (@@cv from C)', %q{
|
||||
class C
|
||||
@@cv = 'str'
|
||||
end
|
||||
@ -1041,7 +1041,7 @@ assert_equal 'can not access class variables from non-main Ractors', %q{
|
||||
}
|
||||
|
||||
# also cached cvar in shareable-objects are not allowed to access from non-main Ractor
|
||||
assert_equal 'can not access class variables from non-main Ractors', %q{
|
||||
assert_equal 'can not access class variables from non-main Ractors (@@cv from C)', %q{
|
||||
class C
|
||||
@@cv = 'str'
|
||||
def self.cv
|
||||
|
||||
13
variable.c
13
variable.c
@ -1195,10 +1195,13 @@ IVAR_ACCESSOR_SHOULD_BE_MAIN_RACTOR(ID id)
|
||||
}
|
||||
}
|
||||
|
||||
#define CVAR_ACCESSOR_SHOULD_BE_MAIN_RACTOR() \
|
||||
if (UNLIKELY(!rb_ractor_main_p())) { \
|
||||
rb_raise(rb_eRactorIsolationError, "can not access class variables from non-main Ractors"); \
|
||||
}
|
||||
static void
|
||||
CVAR_ACCESSOR_SHOULD_BE_MAIN_RACTOR(VALUE klass, ID id)
|
||||
{
|
||||
if (UNLIKELY(!rb_ractor_main_p())) {
|
||||
rb_raise(rb_eRactorIsolationError, "can not access class variables from non-main Ractors (%"PRIsVALUE" from %"PRIsVALUE")", rb_id2str(id), klass);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
ivar_ractor_check(VALUE obj, ID id)
|
||||
@ -4202,7 +4205,7 @@ cvar_overtaken(VALUE front, VALUE target, ID id)
|
||||
}
|
||||
|
||||
#define CVAR_LOOKUP(v,r) do {\
|
||||
CVAR_ACCESSOR_SHOULD_BE_MAIN_RACTOR(); \
|
||||
CVAR_ACCESSOR_SHOULD_BE_MAIN_RACTOR(klass, id); \
|
||||
if (cvar_lookup_at(klass, id, (v))) {r;}\
|
||||
CVAR_FOREACH_ANCESTORS(klass, v, r);\
|
||||
} while(0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user