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.
This commit is contained in:
Nia Waldvogel
2025-11-09 21:12:16 -05:00
committed by Ron Evans
parent 326ca4202e
commit c80da7eb0d
+5 -5
View File
@@ -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
}