summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2021-12-24 12:26:21 +0900
committerKoichi Sasada <ko1@atdot.net>2021-12-24 13:52:02 +0900
commit6050e3e2a6ce2269c56fa74bc5b75a94d064b61f (patch)
tree2547646ab7a59516ddc0f40a6bded331904dfcd7 /vm_insnhelper.c
parente029560b22fef5dd665495a2af01c11ffcd33e12 (diff)
@@cv is not accessible from non-main ractors
Class variables (@@cv) is not accessible from non-main ractors. But without this patch cached @@cv can be read. fix [Bug #18128]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5335
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 37229b5dc0..e01d39de77 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1320,7 +1320,9 @@ vm_getclassvariable(const rb_iseq_t *iseq, const rb_control_frame_t *reg_cfp, ID
VALUE v = Qundef;
RB_DEBUG_COUNTER_INC(cvar_read_inline_hit);
- if (st_lookup(RCLASS_IV_TBL(ic->entry->class_value), (st_data_t)id, &v)) {
+ if (st_lookup(RCLASS_IV_TBL(ic->entry->class_value), (st_data_t)id, &v) &&
+ LIKELY(rb_ractor_main_p())) {
+
return v;
}
}