go
runtime_error
ai_generated
true
fatal error: semacquire: semacquire goroutine 1 [semacquire]: sync.runtime_Semacquire(...)
ID: go/semacquire-deadlock
80%Fix Rate
85%Confidence
0Evidence
2024-07-09First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.18 | active | — | — | — |
| 1.22 | active | — | — | — |
Root Cause
A sync primitive (Mutex, WaitGroup, RWMutex) is held or waited on such that no progress is possible; runtime reports semacquire deadlock.
generic中文
某个同步原语(Mutex、WaitGroup、RWMutex)被持有或等待,导致无法推进;运行时报告 semacquire 死锁。
Workarounds
-
90% success
// Always lock A then B, never B then A. muA.Lock(); muB.Lock(); ...; muB.Unlock(); muA.Unlock()
-
80% success
if !mu.TryLock() { return errors.New("lock timeout") } defer mu.Unlock()
Dead Ends
Common approaches that don't work:
-
85% fail
Atomics cannot express compound invariants; logic still deadlocks.
-
90% fail
Does not resolve lock ordering; can still deadlock.