From 68bcbc54986b9e416e6af7f7e70424981e0764fa Mon Sep 17 00:00:00 2001 From: Nia Waldvogel Date: Sun, 9 Nov 2025 21:12:16 -0500 Subject: [PATCH] runtime (gc_boehm.go): fix world already stopped check This fixes the "gc: world already stopped" check by moving it before gcMarkReachable. Previously the check did not work because gcMarkReachable would hang while waiting for activeTaskLock. --- src/runtime/gc_boehm.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/runtime/gc_boehm.go b/src/runtime/gc_boehm.go index 98b6b86651..08d16760c0 100644 --- a/src/runtime/gc_boehm.go +++ b/src/runtime/gc_boehm.go @@ -48,17 +48,17 @@ func gcInit() //export tinygo_runtime_bdwgc_callback func gcCallback() { + if hasParallelism && needsResumeWorld { + // Should never happen, check for it anyway. + runtimePanic("gc: world already stopped") + } + // Mark globals and all stacks, and stop the world if we're using threading. gcMarkReachable() // If we use a scheduler with parallelism (the threads scheduler for // example), we need to call gcResumeWorld() after scanning has finished. if hasParallelism { - if needsResumeWorld { - // Should never happen, check for it anyway. - runtimePanic("gc: world already stopped") - } - // Note that we need to resume the world after finishing the GC call. needsResumeWorld = true }