Skip to content

Commit 25da274

Browse files
committed
Maybe runnable checks if goroutines are in a waiting state.
Prevents a bug where runnable goroutines are not treated as maybe runnable.
1 parent c9cd1dd commit 25da274

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/runtime/mgc.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,12 @@ top:
10931093
// as the GC marking phase progresses. It returns false for leaked goroutines, or for
10941094
// goroutines which are not yet computed as possibly runnable by the GC.
10951095
func (gp *g) isMaybeRunnable() bool {
1096+
// Check whether the goroutine is actually in a waiting state first.
1097+
if readgstatus(gp) != _Gwaiting {
1098+
// If the goroutine is not waiting, then clearly it is maybe runnable.
1099+
return true
1100+
}
1101+
10961102
switch gp.waitreason {
10971103
case waitReasonSelectNoCases,
10981104
waitReasonChanSendNilChan,

0 commit comments

Comments
 (0)