summaryrefslogtreecommitdiff
path: root/variable.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 /variable.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 'variable.c')
-rw-r--r--variable.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/variable.c b/variable.c
index 4f0f83d203..1cd1c604c3 100644
--- a/variable.c
+++ b/variable.c
@@ -1247,7 +1247,7 @@ rb_obj_fields(VALUE obj, ID field_name)
generic_fields:
{
rb_execution_context_t *ec = GET_EC();
- if (ec->gen_fields_cache.obj == obj) {
+ if (ec->gen_fields_cache.obj == obj && rb_imemo_fields_owner(ec->gen_fields_cache.fields_obj) == obj) {
fields_obj = ec->gen_fields_cache.fields_obj;
}
else {