Skip to content

Synchronize redirected output snapshots - #359

Merged
mthalman merged 1 commit into
dotnet:mainfrom
mthalman:mthalman-fix-output-race
Aug 6, 2026
Merged

Synchronize redirected output snapshots#359
mthalman merged 1 commit into
dotnet:mainfrom
mthalman:mthalman-fix-output-race

Conversation

@mthalman

@mthalman mthalman commented Aug 5, 2026

Copy link
Copy Markdown
Member

Failure

VMR Azure DevOps build 3039585 had two source-only validation failures:

  • SB_CentOSStream10_Offline_CurrentSourceBuiltSdk_Validation_x64
  • SB_Alpine323_Offline_MsftSdk_Validation_x64

In both legs, VerifyWebAPITemplate(language: FSharp) threw System.ArgumentOutOfRangeException with parameter chunkLength from StringBuilder.ToString() while ExecuteHelper was collecting redirected process output.

Suspected cause

PR #354 changed the post-kill process waits in ExecuteHelper.ExecuteProcess, DotNetSdkHelper.ExecuteRunWeb, and DotNetSdkHelper.ExecuteRunUIApp from an unbounded WaitForExit() to a 30-second bounded wait. That change prevents scenario-test hangs when a surviving descendant keeps redirected stdout/stderr handles open, but it also allows execution to continue before the asynchronous readers have reached EOF.

The OutputDataReceived and ErrorDataReceived callbacks append under locks, while the later StringBuilder.ToString() snapshots were outside those locks. If a callback runs while a snapshot is being taken, StringBuilder can observe concurrent mutation and throw. Confidence: high.

Fix

Take the stdout and stderr snapshots under the same existing locks used by their respective callbacks. This preserves the bounded wait while preventing concurrent reads and writes.

Take stdout and stderr snapshots under the same locks used by asynchronous output callbacks so StringBuilder cannot be read while it is being mutated.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@mthalman
mthalman marked this pull request as ready for review August 5, 2026 14:35
@mthalman
mthalman requested a review from nagilson August 5, 2026 14:35
@nagilson

nagilson commented Aug 5, 2026

Copy link
Copy Markdown
Member

@mthalman Approved but I don't have access to this repo nor permission to JIT to give myself permission.

@mthalman
mthalman requested a review from mmitche August 5, 2026 16:35
@mthalman
mthalman enabled auto-merge (squash) August 5, 2026 16:35
@mthalman
mthalman merged commit b56c21e into dotnet:main Aug 6, 2026
8 checks passed
@akoeplinger

Copy link
Copy Markdown
Member

/backport to release/10.0

@mthalman
mthalman deleted the mthalman-fix-output-race branch August 6, 2026 12:49
@akoeplinger

Copy link
Copy Markdown
Member

/backport to release/10.0

@mthalman

mthalman commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

@akoeplinger - There is no backport workflow in this repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants