go
runtime_error
ai_generated
true
fatal error: all goroutines are asleep - deadlock! (select with no ready case)
ID: go/select-no-case-ready-timeout
80%Fix Rate
88%Confidence
0Evidence
2024-09-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.0+ | active | — | — | — |
Root Cause
A select statement has no default and none of its channel cases are ready, and no other goroutine can make them ready, causing a global deadlock.
generic中文
select 语句没有 default 分支,且其 channel 分支都未就绪,也没有其他 goroutine 能使它们就绪,导致全局死锁。
Workarounds
-
90% success
Add a timeout case with time.After and return an error on expiry.
-
85% success
Ensure at least one case is a send that can always proceed, or restructure so the producer runs before the select.
Dead Ends
Common approaches that don't work:
-
70% fail
Busy-looping burns CPU and may still never see data if the producer is also blocked.