Repository navigation
fix: make the TTY progress manager safe against concurrent and repeated Close - #2287
Merged
TerryHowe merged 1 commit intoOct 24, 2026
Merged
Conversation
…ed Close Track and Close only checked whether rendering had already stopped, so a Track that ran while Close was in progress could add to the updating WaitGroup after Close had waited on it, and its status was neither drained nor rendered before Close returned. Two concurrent Close calls could also both close renderDone and panic. Add a closing flag guarded by the manager lock. Close checks and sets it, returning errManagerStopped if it was already set. Track checks it under the write lock and starts updating while still holding the lock. Fixes #2279 Signed-off-by: Wleeaf <[email protected]>
wleeaf
requested review from
TerryHowe,
Wwwsylvia,
sabre1041,
sajayantony and
shizhMSFT
as code owners
October 24, 2026 05:04
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2287 +/- ##
==========================================
+ Coverage 60.78% 60.92% +0.13%
==========================================
Files 140 140
Lines 6092 6098 +6
==========================================
+ Hits 3703 3715 +12
+ Misses 2167 2163 -4
+ Partials 222 220 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
TrackandCloseincmd/oras/internal/display/status/progress/manager.goonly checkedclosed(), which becomes true after rendering has stopped. ATrackthat ran whileClosewas in progress could callupdating.GoafterClosehad already waited on theWaitGroup. Its status was then neither drained nor rendered beforeClosereturned. Two concurrentClosecalls could also both closerenderDoneand panic.This follows the plan in the issue:
closingflag guarded bym.lock.Closechecks and sets it under the lock, and returnserrManagerStoppedif it was already set. This also fixes the double-Closepanic.Trackstill callsrender()first, becauserendertakes the read lock. It then checksclosingunder the write lock and callsupdating.Gowhile still holding the lock, so every successfulTrackis waited for byClose.The eager
render()inTrackis left unchanged, as the issue suggests.Tests (run with
-race):Test_manager_Track_concurrentClose: over 100 rounds, aTrackruns concurrently withClose. EachTrackeither returnserrManagerStopped, or its status is tracked and drained beforeClosereturns.Test_manager_Close_concurrent: over 100 rounds, two concurrentClosecalls do not panic, and exactly one returnserrManagerStopped.Without the fix, both tests failed in 200 of 200 runs (
close of closed channel/tracked status is not drained when manager.Close() returns). With the fix, they passed 1000 of 1000 runs with-race.Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #2279
Please check the following list: