Skip to content

Commit 24b59c9

Browse files
committed
obj_free_object_id: Don't fail if IMEMO/fields entry can't be found
In `build_id2ref_i` we ignore `T_IMEMO` objects, only consider the object they old fields for. So it's possible that the owner object has been garbage collected already, but not its IMEMO/fields.
1 parent 54831b2 commit 24b59c9

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

gc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,8 +2044,10 @@ obj_free_object_id(VALUE obj)
20442044
RUBY_ASSERT(FIXNUM_P(obj_id) || RB_TYPE_P(obj_id, T_BIGNUM));
20452045

20462046
if (!st_delete(id2ref_tbl, (st_data_t *)&obj_id, NULL)) {
2047-
// If we're currently building the table then it's not a bug
2048-
if (id2ref_tbl_built) {
2047+
// If we're currently building the table then it's not a bug.
2048+
// The the object is a T_IMEMO/fields, then it's possible the actual object
2049+
// has been garbage collected already.
2050+
if (id2ref_tbl_built && !RB_TYPE_P(obj, T_IMEMO)) {
20492051
rb_bug("Object ID seen, but not in _id2ref table: object_id=%llu object=%s", NUM2ULL(obj_id), rb_obj_info(obj));
20502052
}
20512053
}

0 commit comments

Comments
 (0)