From 953a1bec48662c57fb40f50a2a4f56f033d842c6 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Tue, 3 Dec 2024 13:18:38 -0800 Subject: [PATCH] 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 --- src/runtime/synctest.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 -- 2.48.1