diff options
author | Jemma Issroff <jemmaissroff@gmail.com> | 2022-10-03 13:52:40 -0400 |
---|---|---|
committer | Aaron Patterson <tenderlove@ruby-lang.org> | 2022-10-11 08:40:56 -0700 |
commit | 913979bede2a1b79109fa2072352882560d55fe0 (patch) | |
tree | b039ef9760ff7b1bf397fd9cac648cc219032cd6 /object.c | |
parent | ad63b668e22e21c352b852f3119ae98a7acf99f1 (diff) |
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 <tenderlove@ruby-lang.org>
Co-Authored-By: John Hawthorn <john@hawthorn.email>
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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 |