Fix intermittent deadlock in AnsiTerminal_OutputProgressFrameIsCorrect#7584
Merged
Evangelink merged 2 commits intomainfrom Mar 20, 2026
Merged
Fix intermittent deadlock in AnsiTerminal_OutputProgressFrameIsCorrect#7584Evangelink merged 2 commits intomainfrom
AnsiTerminal_OutputProgressFrameIsCorrect#7584Evangelink merged 2 commits intomainfrom
Conversation
…t to hang on macOS Co-authored-by: Youssef1313 <31348972+Youssef1313@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix intermittent hang in AnsiTerminal_OutputProgressFrameIsCorrect test
Fix intermittent deadlock in Mar 20, 2026
AnsiTerminal_OutputProgressFrameIsCorrect
Member
Youssef1313
approved these changes
Mar 20, 2026
Evangelink
approved these changes
Mar 20, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an intermittent macOS hang in AnsiTerminal_OutputProgressFrameIsCorrect by avoiding a lock inversion/deadlock between the progress refresh timer thread and test synchronization.
Changes:
- Move
OnProgressStartUpdateinvocation before_lockacquisition inThreadProcto prevent blocking while holding_lock. - Add an explanatory comment documenting the deadlock scenario and rationale.
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TestProgressStateAwareTerminal.cs
Show resolved
Hide resolved
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TestProgressStateAwareTerminal.cs
Show resolved
Hide resolved
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.

AnsiTerminal_OutputProgressFrameIsCorrectwould intermittently hang on macOS due to a deadlock between the background progress refresh timer and the test's synchronization mechanism.Root Cause
ThreadProcinvokedOnProgressStartUpdatewhile holding_lock. The test subscribes to this event with a blockingWaitOne()to gate timer updates for deterministic output. If the timer fired during aTestCompletedcall, the following deadlock occurred:_lock, blocked onstartHandle.WaitOne()WriteToTerminalwaiting to acquire_lockstartHandle.Set()→ hangFix
Move
OnProgressStartUpdate?.Invoke(...)to before thelockacquisition inThreadProc:No production behavior change —
OnProgressStartUpdatehas no subscribers outside tests.Original prompt
AnsiTerminal_OutputProgressFrameIsCorrecthangs intermittently on macOS #7583📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.