matcha
matcha copied to clipboard
BUG: Potential race condition in IDLE watcher Stop()
Describe the bug
In fetcher/idle.go lines 43-71, Stop() and StopAll() methods close stop channel, but:
- Multiple concurrent calls could attempt closing same channel
donechannel read inStopAllAndWait()lacks synchronization- Race condition if
Stop()andStopAll()called simultaneously
func (w *IdleWatcher) Stop() {
close(w.stop) // Panic if already closed
}
To reproduce
- Start IDLE watcher
- Call
Stop()twice concurrently - Panic: "close of closed channel"
Expected behavior
Use sync.Once or check-then-close pattern:
type IdleWatcher struct {
stop chan struct{}
stopOnce sync.Once
// ...
}
func (w *IdleWatcher) Stop() {
w.stopOnce.Do(func() {
close(w.stop)
})
}
Screenshots
N/A
Additional context
- File:
fetcher/idle.go - Lines: 43-50, 63-71
- Severity: Medium - panic on concurrent stop
- Fix complexity: Medium - add sync.Once pattern
This has had no activity for 30 days. It will be closed in 14 days unless updated. Comment or remove the stale label to keep it open.
Closing due to inactivity. Reopen if still relevant.