# 恐慌：运行时错误：无效的内存地址或空指针解引用（原子加载）

- **ID:** `go/atomic-operation-misuse`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

对空指针或未对齐的内存使用原子操作，导致恐慌。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.4 | active | — | — |
| 1.23 | active | — | — |

## 解决方案

1. **Ensure pointer is initialized before atomic operations** (95% 成功率)
   ```
   var val int64
atomic.StoreInt64(&val, 42)
   ```
2. **Use atomic.Value for arbitrary types** (90% 成功率)
   ```
   var v atomic.Value
v.Store(42)
val := v.Load().(int)
   ```

## 无效尝试

- **Using mutex instead of atomic but not initializing pointer** — Mutex also requires valid pointer; same issue. (60% 失败率)
- **Ignoring alignment requirements for atomic operations on struct fields** — Atomic operations require natural alignment; panic may occur on some architectures. (70% 失败率)
