From 913979bede2a1b79109fa2072352882560d55fe0 Mon Sep 17 00:00:00 2001 From: Jemma Issroff Date: Mon, 3 Oct 2022 13:52:40 -0400 Subject: Make inline cache reads / writes atomic with object shapes Prior to this commit, we were reading and writing ivar index and shape ID in inline caches in two separate instructions when getting and setting ivars. This meant there was a race condition with ractors and these caches where one ractor could change a value in the cache while another was still reading from it. This commit instead reads and writes shape ID and ivar index to inline caches atomically so there is no longer a race condition. Co-Authored-By: Aaron Patterson Co-Authored-By: John Hawthorn --- object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'object.c') diff --git a/object.c b/object.c index 648946beb3..929968c4cb 100644 --- a/object.c +++ b/object.c @@ -319,7 +319,7 @@ init_copy(VALUE dest, VALUE obj) // If the object is frozen, the "dup"'d object will *not* be frozen, // so we need to copy the frozen shape's parent to the new object. if (rb_shape_frozen_shape_p(shape_to_set)) { - shape_to_set = shape_to_set->parent; + shape_to_set = rb_shape_get_shape_by_id(shape_to_set->parent_id); } // shape ids are different -- cgit v1.2.1