You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: data race in progress bar field access (Placeholder/Complete/Abort) #469
The Placeholder(), Complete(), and Abort() methods in internal/pb/pb.go modify bar.msg after releasing RLock, which can race with the progress bar rendering goroutine that reads bar.msg concurrently.
Example in Placeholder():
p.mu.RLock()
existing:=p.bars[name]
p.mu.RUnlock()
ifexisting!=nil {
existing.msg=...// write without lock, concurrent read by renderer
}
The same pattern exists in Complete() (line 177) and Abort().
Suggested Fix
Use a write lock (p.mu.Lock()) when modifying bar.msg, or add a per-bar mutex to protect field access.
Context
Found during code review of #468. This is a pre-existing issue, not introduced by that PR.
Fixed by #474. progressBar.msg is now an atomic.Value, so Complete and the render goroutine no longer race on it. Placeholder in #468 uses the same msg.Store. Closing.
Activity
aftersnow commentedon Nov 17, 2026
Fixed by #474.
progressBar.msgis now anatomic.Value, soCompleteand the render goroutine no longer race on it.Placeholderin #468 uses the samemsg.Store. Closing.