-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix ProcessRunner StringBuilder race condition causing assertion failure #124269
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
Conversation
Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
|
@copilot please invoke the code-review skill and post your analysis/results as a comment on this PR |
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.
Pull request overview
This PR addresses a race condition in ProcessRunner’s stdout/stderr capture that can corrupt the shared StringBuilder and trigger StringBuilder.ExpandByABlock assertions during concurrent appends.
Changes:
- Adds synchronization around
_outputCapture.AppendLine(...)in both stdout and stderr event handlers. - Switches synchronization to lock on the
_outputCaptureinstance itself (instead of a separate lock object).
🤖 Copilot Code Review — PR #124225Holistic AssessmentMotivation: The bug is real — Approach: Adding Summary: ✅ LGTM. The fix is minimal, correct, and consistent with the existing file conventions. Detailed Findings✅ Thread-safety fix is correct and sufficientThe two event handlers ( ✅ No lock needed on
|
|
/ba-g DeadLetter on Apple TV, the rest are known |
Description
Closes #124067
ProcessRunner's stdout and stderr handlers concurrently appended to a shared
StringBuilderwithout synchronization, corrupting internal state and triggering assertion failureminBlockCharCount > 0inExpandByABlock.Changes
_outputCaptureStringBuilder in bothStandardOutputEventHandlerandStandardErrorEventHandlerToString()call inIsAvailable- process has already exited, no more events will fireOriginal prompt
This section details on the original issue you should resolve
<issue_title>Assertion failed: minBlockCharCount > 0</issue_title>
<issue_description>Failed in: runtime-coreclr pgo 20260205.1
Failed tests:
Error message:
Stack trace: