From e3875dd0f8f11d9dbdc25b400f387c406b799cb5 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Mon, 27 Nov 2023 11:13:47 -0500 Subject: [PATCH] Don't incremental mark when GC stressful Incremental marking prevents the GC from fully executing, so it may fail to catch certain bugs. --- gc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gc.c b/gc.c index 7daddd5364..eada017888 100644 --- a/gc.c +++ b/gc.c @@ -9404,7 +9404,6 @@ static int gc_start(rb_objspace_t *objspace, unsigned int reason) { unsigned int do_full_mark = !!(reason & GPR_FLAG_FULL_MARK); - unsigned int immediate_mark = reason & GPR_FLAG_IMMEDIATE_MARK; /* reason may be clobbered, later, so keep set immediate_sweep here */ objspace->flags.immediate_sweep = !!(reason & GPR_FLAG_IMMEDIATE_SWEEP); @@ -9449,7 +9448,9 @@ gc_start(rb_objspace_t *objspace, unsigned int reason) reason |= GPR_FLAG_MAJOR_BY_FORCE; /* GC by CAPI, METHOD, and so on. */ } - if (objspace->flags.dont_incremental || immediate_mark) { + if (objspace->flags.dont_incremental || + reason & GPR_FLAG_IMMEDIATE_MARK || + ruby_gc_stressful) { objspace->flags.during_incremental_marking = FALSE; } else {