Skip to content

Commit 1abb609

Browse files
peterzhu2118matzbot
authored andcommitted
[ruby/mmtk] Check that a and b are valid objects in write barrier
ruby/mmtk@350625ebb3
1 parent 08f6b86 commit 1abb609

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

gc/mmtk/mmtk.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,18 @@ rb_gc_impl_writebarrier(void *objspace_ptr, VALUE a, VALUE b)
963963

964964
if (SPECIAL_CONST_P(b)) return;
965965

966+
#ifdef MMTK_DEBUG
967+
if (!rb_gc_impl_pointer_to_heap_p(objspace_ptr, (void *)a)) {
968+
char buff[256];
969+
rb_bug("a: %s is not an object", rb_raw_obj_info(buff, 256, a));
970+
}
971+
972+
if (!rb_gc_impl_pointer_to_heap_p(objspace_ptr, (void *)b)) {
973+
char buff[256];
974+
rb_bug("b: %s is not an object", rb_raw_obj_info(buff, 256, b));
975+
}
976+
#endif
977+
966978
mmtk_object_reference_write_post(cache->mutator, (MMTk_ObjectReference)a);
967979
}
968980

0 commit comments

Comments
 (0)