matcha
matcha copied to clipboard
BUG: Race condition in Image ID allocation
Describe the bug
In view/html.go:281, var nextImageID uint32 = 1000 is incremented by allocImageID() using nextImageID++. If multiple goroutines request an ID simultaneously, this will cause a race condition and duplicate IDs.
To reproduce
Run the app with -race while rendering multiple terminal images concurrently.
Expected behavior
Use atomic.Uint32 or atomic.AddUint32(&nextImageID, 1) for thread-safe increments.
Already handled, close it.