go runtime_error ai_generated true

fatal error: all goroutines are asleep - deadlock!

ID: go/deadlock-all-goroutines-asleep

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-01-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.0 active
1.23 active

Root Cause

All goroutines are blocked waiting on channels or locks with no way to proceed, causing a program deadlock.

generic

中文

所有goroutine都阻塞在通道或锁上,无法继续执行,导致程序死锁。

Workarounds

  1. 90% success
    Use buffered channels or select with default to avoid blocking indefinitely. Ensure there is a way for goroutines to exit.
  2. 85% success
    Implement a timeout using context.WithTimeout to break deadlocks.

Dead Ends

Common approaches that don't work:

  1. 90% fail

    If the existing goroutines are waiting on each other, adding more will not resolve the circular wait.

  2. 80% fail

    Sleep does not resolve the underlying synchronization issue; it only delays the deadlock detection.

  3. 70% fail

    This breaks the program's logic and may introduce data races.