# fatal error: concurrent atomic operations on misaligned memory

- **ID:** `go/goroutine-atomic-load-store-race`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Using atomic operations on a variable that is not properly aligned, causing a panic on some architectures (e.g., ARM).

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.20 | active | — | — |
| 1.21 | active | — | — |

## Workarounds

1. **Ensure atomic variables are 64-bit aligned, e.g., by using a struct with proper padding.** (95% success)
   ```
   type Aligned struct {
    _    [0]int64 // ensure alignment
    val  int64
}
var a Aligned
atomic.StoreInt64(&a.val, 42)
fmt.Println(atomic.LoadInt64(&a.val))
   ```
2. **Use sync.Mutex instead of atomic for non-critical paths.** (90% success)
   ```
   var mu sync.Mutex
var val int64
mu.Lock()
val = 42
mu.Unlock()
mu.Lock()
fmt.Println(val)
mu.Unlock()
   ```

## Dead Ends

- **Assuming atomic operations work on any variable regardless of alignment.** — Some platforms require 64-bit alignment for 64-bit atomics; misalignment causes panic. (90% fail)
- **Using a struct with atomic fields without ensuring alignment.** — Fields may be packed in a way that causes misalignment. (80% fail)
