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
bug: status.Render mutates the status under a read lock (data race between concurrent renders) #2289
status.Render in cmd/oras/internal/display/status/progress/status.go holds only s.lock.RLock(), but it writes to the status. It advances the spinner (s.mark.symbol() increments s.mark), and calculateSpeed() appends to the speed window (s.speed.Add, which updates point, next and size).
manager.render() also runs under a read lock (m.lock.RLock()), and it is called from two places: the ticker goroutine, and Track on the caller's goroutine. When several blobs start at once (copy/push/pull run with concurrency 3 by default), several render() calls can run at the same time and render the same status concurrently. The race detector reports this as a data race on status.mark and on the speedWindow fields.
Besides the race report, a lost update on w.size++ can push size past the window's capacity. After that, size never equals len(w.point) again, and Mean() can compute a negative begin index.
What did you expect to happen?
Rendering a status should be safe when render() runs concurrently. Render mutates the status, so it should take the write lock, like the update* functions in the same file.
How can we reproduce it?
Add this test to cmd/oras/internal/display/status/progress and run go test -race -run Test_concurrentTrack -count=20 .:
The wrapper is only there because the mock console isn't safe for concurrent use (the real console writes straight to the terminal file). On main, WARNING: DATA RACE between two (*status).Render calls (spinner.symbol / speedWindow.Add) appears in most runs (16 of 20 here).
Activity