From f6dcab5f50bc3ab00b17d3ce84bd906b176baa7a Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Fri, 20 Sep 2024 10:52:43 -0400 Subject: [PATCH] Assert that objects in write barrier are not dead --- gc/default.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gc/default.c b/gc/default.c index addaf01fc2..65aacb70a3 100644 --- a/gc/default.c +++ b/gc/default.c @@ -6126,6 +6126,13 @@ rb_gc_impl_writebarrier(void *objspace_ptr, VALUE a, VALUE b) if (SPECIAL_CONST_P(b)) rb_bug("rb_gc_writebarrier: b is special const: %"PRIxVALUE, b); } + GC_ASSERT(RB_BUILTIN_TYPE(a) != T_NONE); + GC_ASSERT(RB_BUILTIN_TYPE(a) != T_MOVED); + GC_ASSERT(RB_BUILTIN_TYPE(a) != T_ZOMBIE); + GC_ASSERT(RB_BUILTIN_TYPE(b) != T_NONE); + GC_ASSERT(RB_BUILTIN_TYPE(b) != T_MOVED); + GC_ASSERT(RB_BUILTIN_TYPE(b) != T_ZOMBIE); + retry: if (!is_incremental_marking(objspace)) { if (!RVALUE_OLD_P(objspace, a) || RVALUE_OLD_P(objspace, b)) {