# WARNING: DATA RACE: Write by goroutine X, Read by goroutine Y (sync.Pool)

- **ID:** `go/goroutine-sync-pool-race`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Using sync.Pool without proper understanding; objects in pool may be accessed concurrently without synchronization.

## Version Compatibility

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

## Workarounds

1. **Ensure pooled objects are not shared between goroutines** (85% success)
   ```
   pool := &sync.Pool{New: func() interface{} { return &MyStruct{} }}
go func() {
    obj := pool.Get().(*MyStruct)
    // use obj exclusively
    pool.Put(obj)
}()
   ```
2. **Use mutex inside pooled object if sharing is needed** (80% success)
   ```
   type MyStruct struct {
    mu sync.Mutex
    data int
}
obj := pool.Get().(*MyStruct)
obj.mu.Lock()
obj.data = 42
obj.mu.Unlock()
pool.Put(obj)
   ```

## Dead Ends

- **Assuming sync.Pool provides synchronization** — sync.Pool does not synchronize access to pooled objects; only the pool itself is safe. (90% fail)
- **Using global variables instead of pool** — Global variables are shared; race condition persists. (80% fail)
