From ef65183692789f80dc1c1ad569a449edfdd46120 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 5 Sep 2023 09:27:11 -0400 Subject: [PATCH] Add check for T_NONE in rb_gc_mark_weak This commit adds a check for T_NONE in rb_gc_mark_weak, just like gc_mark_ptr. This will help debugging. --- gc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gc.c b/gc.c index 2863240aa6..b529a472ad 100644 --- a/gc.c +++ b/gc.c @@ -6903,6 +6903,11 @@ rb_gc_mark_weak(VALUE *ptr) GC_ASSERT(objspace->rgengc.parent_object == 0 || FL_TEST(objspace->rgengc.parent_object, FL_WB_PROTECTED)); + if (UNLIKELY(RB_TYPE_P(obj, T_NONE))) { + rp(obj); + rb_bug("try to mark T_NONE object"); + } + /* If we are in a minor GC and the other object is old, then obj should * already be marked and cannot be reclaimed in this GC cycle so we don't * need to add it to the weak refences list. */