go runtime_error ai_generated true

致命错误:所有 goroutine 都处于休眠状态 - 死锁!

fatal error: all goroutines are asleep - deadlock!

ID: go/fatal-error-all-goroutines-asleep-deadlock

其他格式: JSON · Markdown 中文 · English
80%修复率
90%置信度
0证据数
2024-01-15首次发现

版本兼容性

版本状态引入弃用备注
1.0+ active

根因分析

所有 goroutine 都阻塞在 channel 或锁上,无法继续推进,Go 运行时死锁检测器触发。

English

All goroutines are blocked waiting on channels/locks with no possibility of progress; the Go runtime deadlock detector fires.

generic

解决方案

  1. 95% 成功率
    ch := make(chan int, 1)
    ch <- 1 // no receiver needed for buffered channel
  2. 90% 成功率
    select {
    case v := <-ch:
        _ = v
    case <-time.After(time.Second):
        return errors.New("timeout")
    }

无效尝试

常见但无效的做法:

  1. 90% 失败

    Sleep does not unblock the sender; the deadlock detector still fires once all goroutines park.

  2. 95% 失败

    fatal error from the runtime is not recoverable via recover(); it calls exit directly.