go
runtime_error
ai_generated
true
fatal error: all goroutines are asleep - deadlock! (select with no cases)
ID: go/select-empty-deadlock
80%Fix Rate
90%Confidence
0Evidence
2024-04-18First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.0+ | active | — | — | — |
Root Cause
A select statement with no cases blocks forever, and if all goroutines are blocked, the runtime detects deadlock.
generic中文
select 语句没有任何 case,会永远阻塞,如果所有 goroutine 都阻塞,运行时会检测到死锁。
Workarounds
-
98% success
select { case <-ch: // handle } -
95% success
select { case <-done: return case <-ch: // handle }
Dead Ends
Common approaches that don't work:
-
60% fail
Default case may cause busy loop and still not solve logical deadlock
-
90% fail
Sleep does not help; select with no cases is invalid