go
runtime_error
ai_generated
true
fatal error: all goroutines are asleep - deadlock! (goroutine 1 [chan send])
ID: go/goroutine-leak-no-receiver
80%Fix Rate
86%Confidence
0Evidence
2024-04-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.20 | active | — | — | — |
| 1.21 | active | — | — | — |
Root Cause
A goroutine is stuck sending to a channel with no active receiver, and the main goroutine is waiting for it, causing a deadlock.
generic中文
一个 goroutine 在向没有活动接收者的通道发送时卡住,主 goroutine 在等待它,导致死锁。
Workarounds
-
95% success
ch := make(chan int); go func() { <-ch }(); ch <- 42 -
85% success
ch := make(chan int, 1); ch <- 42
Dead Ends
Common approaches that don't work:
-
75% fail
If sender sends more than buffer size, it still blocks without receiver.
-
90% fail
Sleep doesn't add a receiver; block remains after sleep.