Skip to content

Commit 4d9fa68

Browse files
committed
Check that object is live in each_object
Fixes crash in: 10_000.times.map do Object.new end run_gc = true ObjectSpace.each_object do |o| if run_gc GC.start run_gc = false end puts o end
1 parent f330782 commit 4d9fa68

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

gc/mmtk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,8 @@ each_object(struct objspace *objspace, int (*func)(VALUE, void *), void *data)
848848

849849
VALUE *obj_ptr;
850850
rb_darray_foreach(objs, i, obj_ptr) {
851+
if (!mmtk_is_live_object((MMTk_ObjectReference)*obj_ptr)) continue;
852+
851853
if (func(*obj_ptr, data) != 0) {
852854
break;
853855
}

0 commit comments

Comments
 (0)