summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-05-15 12:14:53 +0200
committerJean Boussier <[email protected]>2025-05-15 16:06:52 +0200
commit60ffb714d251878753ebf66e68149311c728cac6 ()
treed9cb46a81af9313ad6faa6faa559fd1c4c7c2c66
parented632cd0bacc710b03809c903a978d3fa2cfedfe (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: Merged: https://.com/ruby/ruby/pull/13347
-rw-r--r--eval.c6
-rw-r--r--ext/objspace/objspace_dump.c8
-rw-r--r--gc.c11
-rw-r--r--iseq.c1
-rw-r--r--shape.h3
5 files changed, 23 insertions, 6 deletions
@@ -529,10 +529,14 @@ exc_setup_message(const rb_execution_context_t *ec, VALUE mesg, VALUE *cause)
rb_exc_check_circular_cause(*cause);
#else
VALUE c = *cause;
- while (!NIL_P(c = rb_attr_get(c, id_cause))) {
if (c == mesg) {
rb_raise(rb_eArgError, "circular causes");
}
}
#endif
}
@@ -414,9 +414,11 @@ dump_object(VALUE obj, struct dump_config *dc)
dump_append(dc, obj_type(obj));
dump_append(dc, "\"");
- size_t shape_id = rb_obj_shape_id(obj);
- dump_append(dc, ", \"shape_id\":");
- dump_append_sizet(dc, shape_id);
dump_append(dc, ", \"slot_size\":");
dump_append_sizet(dc, dc->cur_page_slot_size);
@@ -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);
default:
break;
}
@@ -1960,6 +1963,8 @@ build_id2ref_i(VALUE obj, void *data)
st_insert(id2ref_tbl, RCLASS(obj)->object_id, obj);
}
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)
{
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);
}
static enum rb_id_table_iterator_result
@@ -1530,7 +1530,6 @@ iseqw_new(const rb_iseq_t *iseq)
/* cache a wrapper object */
RB_OBJ_WRITE((VALUE)iseq, &iseq->wrapper, obj);
- RB_OBJ_FREEZE((VALUE)iseq);
return obj;
}
@@ -94,12 +94,15 @@ static inline shape_id_t
get_shape_id_from_flags(VALUE obj)
{
RUBY_ASSERT(!RB_SPECIAL_CONST_P(obj));
return (shape_id_t)((RBASIC(obj)->flags) >> SHAPE_FLAG_SHIFT);
}
static inline void
set_shape_id_in_flags(VALUE obj, shape_id_t shape_id)
{
// Ractors are occupying the upper 32 bits of flags, but only in debug mode
// Object shapes are occupying top bits
RBASIC(obj)->flags &= SHAPE_FLAG_MASK;