go runtime_error ai_generated true

fatal error: all goroutines are asleep - deadlock! (channel buffer full)

ID: go/channel-buffer-overflow-block

Also available as: JSON · Markdown · 中文
80%Fix Rate
88%Confidence
0Evidence
2024-09-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.0+ active — — —

Root Cause

A goroutine attempts to send to a buffered channel that is full, and no receiver is available, causing a deadlock.

generic

中文

某个 goroutine 试图向已满的带缓冲 channel 发送数据,且没有接收者,导致死锁。

Workarounds

  1. 95% success
    go func() {
        for v := range ch {
            // process
        }
    }()
  2. 90% success
    select {
    case ch <- v:
    default:
        // handle full buffer
    }

Dead Ends

Common approaches that don't work:

  1. 80% fail

    May delay but not prevent deadlock if no receiver

  2. 60% fail

    May lose data if not handled properly