go
runtime_error
ai_generated
true
panic: runtime error: invalid memory address or nil pointer dereference (using atomic on non-pointer)
ID: go/atomic-misuse
80%Fix Rate
86%Confidence
0Evidence
2025-01-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.19 | active | — | — | — |
| 1.22 | active | — | — | — |
Root Cause
Using atomic operations on non-atomic variables or misusing atomic functions, causing data races and panics.
generic中文
在非原子变量上使用原子操作或误用原子函数,导致数据竞争和 panic。
Workarounds
-
90% success
var v atomic.Int32 v.Store(42) val := v.Load()
-
85% success
var x int64 atomic.AddInt64(&x, 1) // correct usage
Dead Ends
Common approaches that don't work:
-
80% fail
Regular variables are not thread-safe, causing data races.
-
50% fail
Redundant and may cause performance issues, but not a direct fix for misuse.