mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 10:37:46 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user