Skip to content

Commit c80da7e

Browse files
niaowdeadprogram
authored andcommitted
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.
1 parent 326ca42 commit c80da7e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/runtime/gc_boehm.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ func gcInit()
4848

4949
//export tinygo_runtime_bdwgc_callback
5050
func gcCallback() {
51+
if hasParallelism && needsResumeWorld {
52+
// Should never happen, check for it anyway.
53+
runtimePanic("gc: world already stopped")
54+
}
55+
5156
// Mark globals and all stacks, and stop the world if we're using threading.
5257
gcMarkReachable()
5358

5459
// If we use a scheduler with parallelism (the threads scheduler for
5560
// example), we need to call gcResumeWorld() after scanning has finished.
5661
if hasParallelism {
57-
if needsResumeWorld {
58-
// Should never happen, check for it anyway.
59-
runtimePanic("gc: world already stopped")
60-
}
61-
6262
// Note that we need to resume the world after finishing the GC call.
6363
needsResumeWorld = true
6464
}

0 commit comments

Comments
 (0)