Skip to content

Commit f229787

Browse files
lucoffegopherbot
authored andcommitted
runtime: prevent double lock in checkdead by unlocking before throws
This change resolves an issue where checkdead could result in a double lock when shedtrace is enabled. This fix involves adding unlocks before all throws in the checkdead function to ensure the scheduler lock is properly released. Fixes #59758 Change-Id: If3ddf9969f4582c3c88dee9b9ecc355a63958103 Reviewed-on: https://go-review.googlesource.com/c/go/+/487375 Run-TryBot: Michael Pratt <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Auto-Submit: Michael Pratt <[email protected]> Reviewed-by: Michael Pratt <[email protected]>
1 parent 6328e44 commit f229787

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/runtime/proc.go

+4
Original file line numberDiff line numberDiff line change
@@ -5194,6 +5194,7 @@ func checkdead() {
51945194
}
51955195
if run < 0 {
51965196
print("runtime: checkdead: nmidle=", sched.nmidle, " nmidlelocked=", sched.nmidlelocked, " mcount=", mcount(), " nmsys=", sched.nmsys, "\n")
5197+
unlock(&sched.lock)
51975198
throw("checkdead: inconsistent counts")
51985199
}
51995200

@@ -5211,6 +5212,7 @@ func checkdead() {
52115212
_Grunning,
52125213
_Gsyscall:
52135214
print("runtime: checkdead: find g ", gp.goid, " in status ", s, "\n")
5215+
unlock(&sched.lock)
52145216
throw("checkdead: runnable g")
52155217
}
52165218
})
@@ -5229,12 +5231,14 @@ func checkdead() {
52295231
if pp == nil {
52305232
// There should always be a free P since
52315233
// nothing is running.
5234+
unlock(&sched.lock)
52325235
throw("checkdead: no p for timer")
52335236
}
52345237
mp := mget()
52355238
if mp == nil {
52365239
// There should always be a free M since
52375240
// nothing is running.
5241+
unlock(&sched.lock)
52385242
throw("checkdead: no m for timer")
52395243
}
52405244
// M must be spinning to steal. We set this to be

0 commit comments

Comments
 (0)