diff options
author | Jean Boussier <[email protected]> | 2025-05-15 12:14:53 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-05-15 16:06:52 +0200 |
commit | 60ffb714d251878753ebf66e68149311c728cac6 (patch) | |
tree | d9cb46a81af9313ad6faa6faa559fd1c4c7c2c66 /gc.c | |
parent | ed632cd0bacc710b03809c903a978d3fa2cfedfe (diff) |
Ensure shape_id is never used on T_IMEMO
It doesn't make sense to set ivars or anything shape
related on a T_IMEMO.
Co-Authored-By: John Hawthorn <[email protected]>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13347
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -1934,6 +1934,9 @@ object_id(VALUE obj) // in different namespaces, so we cannot store the object id // in fields. return class_object_id(obj); + case T_IMEMO: + rb_bug("T_IMEMO can't have an object_id"); + break; default: break; } @@ -1960,6 +1963,8 @@ build_id2ref_i(VALUE obj, void *data) st_insert(id2ref_tbl, RCLASS(obj)->object_id, obj); } break; + case T_IMEMO: + break; default: if (rb_shape_obj_has_id(obj)) { st_insert(id2ref_tbl, rb_obj_id(obj), obj); @@ -2007,6 +2012,10 @@ object_id_to_ref(void *objspace_ptr, VALUE object_id) static inline void obj_free_object_id(VALUE obj) { + if (RB_BUILTIN_TYPE(obj) == T_IMEMO) { + return; + } + VALUE obj_id = 0; if (RB_UNLIKELY(id2ref_tbl)) { switch (BUILTIN_TYPE(obj)) { @@ -2210,7 +2219,7 @@ rb_obj_id(VALUE obj) bool rb_obj_id_p(VALUE obj) { - return rb_shape_obj_has_id(obj); + return !RB_TYPE_P(obj, T_IMEMO) && rb_shape_obj_has_id(obj); } static enum rb_id_table_iterator_result |