-
Notifications
You must be signed in to change notification settings - Fork 1.3k
.NET: Address PR comments #4255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -830,12 +830,17 @@ private async Task BuildSampleAsync(string samplePath) | |
|
|
||
| using Process buildProcess = new() { StartInfo = buildInfo }; | ||
| buildProcess.Start(); | ||
|
|
||
| // Read both streams asynchronously to avoid deadlocks from filled pipe buffers | ||
| Task<string> stdoutTask = buildProcess.StandardOutput.ReadToEndAsync(); | ||
| Task<string> stderrTask = buildProcess.StandardError.ReadToEndAsync(); | ||
| await buildProcess.WaitForExitAsync(); | ||
|
|
||
|
Comment on lines
+834
to
838
|
||
| string stderr = await stderrTask; | ||
| if (buildProcess.ExitCode != 0) | ||
| { | ||
| string stderr = await buildProcess.StandardError.ReadToEndAsync(); | ||
| throw new InvalidOperationException($"Failed to build sample at {samplePath}: {stderr}"); | ||
| string stdout = await stdoutTask; | ||
| throw new InvalidOperationException($"Failed to build sample at {samplePath}:\n{stdout}\n{stderr}"); | ||
| } | ||
|
|
||
| this._outputHelper.WriteLine($"Build completed for {samplePath}."); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stdoutTaskis started but never awaited on the success path. SincebuildProcessis disposed at the end of the method, the outstanding read can fault and produce unobserved task exceptions or flaky behavior. Suggest awaiting bothstdoutTaskandstderrTaskunconditionally (e.g.,await Task.WhenAll(...)) before exiting the method.