From: Damien Neil Date: Tue, 3 Dec 2024 21:18:38 +0000 (-0800) Subject: runtime: avoid defer on system stack in synctestidle_c X-Git-Tag: go1.24rc1~39 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=953a1bec48662c57fb40f50a2a4f56f033d842c6;p=gostls13.git runtime: avoid defer on system stack in synctestidle_c Fixes #70661 Change-Id: I58a465cfb1cd16709ffbb072eca0997569540074 Reviewed-on: https://go-review.googlesource.com/c/go/+/633281 Auto-Submit: Damien Neil Reviewed-by: Michael Pratt LUCI-TryBot-Result: Go LUCI --- diff --git a/src/runtime/synctest.go b/src/runtime/synctest.go index 09748d5c1c..498c3b92dd 100644 --- a/src/runtime/synctest.go +++ b/src/runtime/synctest.go @@ -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