mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-15 08:23:41 +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
|
//export tinygo_runtime_bdwgc_callback
|
||||||
func gcCallback() {
|
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.
|
// Mark globals and all stacks, and stop the world if we're using threading.
|
||||||
gcMarkReachable()
|
gcMarkReachable()
|
||||||
|
|
||||||
// If we use a scheduler with parallelism (the threads scheduler for
|
// If we use a scheduler with parallelism (the threads scheduler for
|
||||||
// example), we need to call gcResumeWorld() after scanning has finished.
|
// example), we need to call gcResumeWorld() after scanning has finished.
|
||||||
if hasParallelism {
|
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.
|
// Note that we need to resume the world after finishing the GC call.
|
||||||
needsResumeWorld = true
|
needsResumeWorld = true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user