From c8c7d1ab23c98b6e00fbf273457c67383f5f4d16 Mon Sep 17 00:00:00 2001 From: dearblue Date: Tue, 23 Apr 2024 22:25:54 +0900 Subject: [PATCH] Don't `mrb_realloc_simple()` call `mrb_full_gc()` in the sweep phase `mrb_env_unshare()` calls `mrb_realloc_simple()` and follows `mrb_full_gc()` to avoid an infinite loop where `mrb_env_unshare()` is called again. This does not occur at this time, but may occur in subsequent patches. --- src/gc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gc.c b/src/gc.c index f3c7e3c6b..2833824e9 100644 --- a/src/gc.c +++ b/src/gc.c @@ -190,10 +190,12 @@ mrb_realloc_simple(mrb_state *mrb, void *p, size_t len) void *p2; #if defined(MRB_GC_STRESS) && defined(MRB_DEBUG) - mrb_full_gc(mrb); + if (mrb->gc.state != MRB_GC_STATE_SWEEP) { + mrb_full_gc(mrb); + } #endif p2 = (mrb->allocf)(mrb, p, len, mrb->allocf_ud); - if (!p2 && len > 0 && mrb->gc.heaps) { + if (!p2 && len > 0 && mrb->gc.heaps && mrb->gc.state != MRB_GC_STATE_SWEEP) { mrb_full_gc(mrb); p2 = (mrb->allocf)(mrb, p, len, mrb->allocf_ud); }