go
runtime_error
ai_generated
true
panic: sync: Cond.Broadcast called without lock held
ID: go/condition-broadcast-without-lock
80%Fix Rate
87%Confidence
0Evidence
2024-10-09First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.18 | active | — | — | — |
| 1.20 | active | — | — | — |
| 1.22 | active | — | — | — |
Root Cause
sync.Cond.Broadcast() or Signal() is called without holding the associated Locker, violating the documented contract.
generic中文
在未持有相关联的 Locker 的情况下调用 sync.Cond.Broadcast() 或 Signal(),违反了文档约定。
Workarounds
-
96% success
c.L.Lock() // mutate predicate c.Broadcast() c.L.Unlock()
-
85% success
close(done) // wakes all waiters without a Cond
Dead Ends
Common approaches that don't work:
-
85% fail
Still not holding the lock when Broadcast executes; panic persists.
-
70% fail
Burns CPU and reintroduces races on the shared predicate.