]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: avoid defer on system stack in synctestidle_c
authorDamien Neil <dneil@google.com>
Tue, 3 Dec 2024 21:18:38 +0000 (13:18 -0800)
committerGopher Robot <gobot@golang.org>
Tue, 3 Dec 2024 21:42:30 +0000 (21:42 +0000)
Fixes #70661

Change-Id: I58a465cfb1cd16709ffbb072eca0997569540074
Reviewed-on: https://go-review.googlesource.com/c/go/+/633281
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/runtime/synctest.go

index 09748d5c1cd23c50c8f4a30c08a3cebed5454577..498c3b92dd07966c178a4afa1347e2f4697f7a75 100644 (file)
@@ -217,13 +217,15 @@ func synctestRun(f func()) {
 
 func synctestidle_c(gp *g, _ unsafe.Pointer) bool {
        lock(&gp.syncGroup.mu)
-       defer unlock(&gp.syncGroup.mu)
+       canIdle := true
        if gp.syncGroup.running == 0 && gp.syncGroup.active == 1 {
                // All goroutines in the group have blocked or exited.
-               return false
+               canIdle = false
+       } else {
+               gp.syncGroup.active--
        }
-       gp.syncGroup.active--
-       return true
+       unlock(&gp.syncGroup.mu)
+       return canIdle
 }
 
 //go:linkname synctestWait internal/synctest.Wait