go
runtime_error
ai_generated
true
fatal error: all goroutines are asleep - deadlock! (buffered channel full)
ID: go/goroutine-channel-buffer-overflow
80%Fix Rate
83%Confidence
0Evidence
2025-02-28First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.0 | active | — | — | — |
| 1.21 | active | — | — | — |
Root Cause
Sending to a buffered channel that is full, with no receiver ready, causing sender to block indefinitely.
generic中文
向已满的缓冲通道发送数据,没有接收者就绪,导致发送者无限阻塞。
Workarounds
-
90% success Ensure sufficient consumer goroutines to drain channel
ch := make(chan int, 10) go func() { for val := range ch { // consume } }() for i := 0; i < 20; i++ { ch <- i } -
85% success Use unbuffered channel with proper synchronization
ch := make(chan int) go func() { for val := range ch { // consume } }() ch <- 42 // blocks until receiver ready
Dead Ends
Common approaches that don't work:
-
Increasing buffer size arbitrarily
70% fail
Only delays the problem; if consumers are missing, buffer will fill again.
-
Using non-blocking send with select default
60% fail
Default case drops data; may lose messages.