aboutsummaryrefslogtreecommitdiffstats
path: root/variable.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-10-22 00:36:53 +0900
committerKoichi Sasada <ko1@atdot.net>2020-10-22 00:43:44 +0900
commit0c0d0752f1fefd9b085f191b62946a811763ef1b (patch)
tree17b70a64b83d53becde72478ecca76914285893e /variable.c
parent96293784779c000cdb5c07dd80be0dc208f8eeb9 (diff)
downloadruby-0c0d0752f1fefd9b085f191b62946a811763ef1b.tar.gz
allow to access ivars of frozen shareable objects
Accessing a shareable object is prohibitted because it can cause race condition, but if the shareable object is frozen, there is no problem to access ivars.
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/variable.c b/variable.c
index 795ee3fb0a..8ac40efe80 100644
--- a/variable.c
+++ b/variable.c
@@ -922,7 +922,8 @@ generic_ivtbl(VALUE obj, ID id, bool force_check_ractor)
{
ASSERT_vm_locking();
- if ((force_check_ractor || rb_is_instance_id(id)) && // not internal ID
+ if ((force_check_ractor || LIKELY(rb_is_instance_id(id)) /* not internal ID */ ) &&
+ !RB_OBJ_FROZEN_RAW(obj) &&
UNLIKELY(!rb_ractor_main_p()) &&
UNLIKELY(rb_ractor_shareable_p(obj))) {
rb_raise(rb_eRuntimeError, "can not access instance variables of shareable objects from non-main Ractors");