summaryrefslogtreecommitdiff
path: root/imemo.c
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2025-08-21 13:24:45 +0200
committerJean Boussier <jean.boussier@gmail.com>2025-08-21 14:17:29 +0200
commitb6bf44ae0f0196c58a07e13ac1bd7adafd13f8b2 (patch)
treed0fa52f182518cfa0fb6d8a573f80d0b3060e884 /imemo.c
parenta837ec0962674284de322bfe9b336a410146589d (diff)
variable.c: handle cleared fields_obj in genfields cache
[Bug #21547] Followup: https://github.com/ruby/ruby/pull/14201 When adding an instance variable and the IMEMO/fields need to be larger, we allocate a new one and clear the old one. Since the old one may still be in other ec's cache, on a hit we must check the IMEMO/fields isn't a stale one.
Diffstat (limited to 'imemo.c')
-rw-r--r--imemo.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/imemo.c b/imemo.c
index fde5b15ad6..2fde22a3db 100644
--- a/imemo.c
+++ b/imemo.c
@@ -3,6 +3,7 @@
#include "id_table.h"
#include "internal.h"
#include "internal/imemo.h"
+#include "internal/object.h"
#include "internal/st.h"
#include "vm_callinfo.h"
@@ -208,6 +209,8 @@ rb_imemo_fields_clear(VALUE fields_obj)
else {
RBASIC_SET_SHAPE_ID(fields_obj, ROOT_SHAPE_ID);
}
+ // Invalidate the ec->gen_fields_cache.
+ RBASIC_CLEAR_CLASS(fields_obj);
}
/* =========================================================================