From 90ba2f4e1c60324f4d4a958a8a28bc2bbd1968b7 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 6 Jun 2025 21:01:24 +0200 Subject: [PATCH] Add missing lock around `redblack_cache_ancestors` This used to be protected because all shape code was under a lock, but now that the shape tree is lock-free we still need to lock around the red-black cache. Co-Authored-By: Luke Gruber --- shape.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shape.c b/shape.c index 4a6d00368e..becd1aa8c5 100644 --- a/shape.c +++ b/shape.c @@ -530,7 +530,9 @@ rb_shape_alloc_new_child(ID id, rb_shape_t *shape, enum shape_type shape_type) RUBY_ASSERT(new_shape->capacity > shape->next_field_index); new_shape->next_field_index = shape->next_field_index + 1; if (new_shape->next_field_index > ANCESTOR_CACHE_THRESHOLD) { - redblack_cache_ancestors(new_shape); + RB_VM_LOCKING() { + redblack_cache_ancestors(new_shape); + } } break; case SHAPE_ROOT: