8000 [release/v7.4] Fix the NREs when writing to console from multiple threads by pwshBot · Pull Request #25503 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

[release/v7.4] Fix the NREs when writing to console from multiple threads #25503

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

Open
wants to merge 1 commit into
base: release/v7.4
Choose a base branch
from

Conversation

pwshBot
Copy link
Collaborator
@pwshBot pwshBot commented May 3, 2025

Backport of #25440 to release/v7.4

Triggered by @TravisEz13 on behalf of @kborowinski

Original CL Label: CL-General

/cc @PowerShell/powershell-maintainers

Impact

Choose either tooling or Customer impact.

Tooling Impact

  • Required tooling change
  • Optional tooling change (include reasoning)

Customer Impact

  • Customer reported
  • Found internally

Comment from @kborowinski

#25440 (comment)

I understand the decision not to backport this PR to the LTS version, but I would like to clarify that the actual script results are affected in PS 7.4.X and up.

I first reported this issue on the 7Zip4PowerShell repo, where the unpacking process was crashing mid-task.
I proposed a PR that was merged to implement a workaround that swallows NREs coming from progress pane:

try {
    worker.Progress.StatusDescription = "Finished";
    worker.Progress.RecordType = ProgressRecordType.Completed;
    WriteProgress(worker.Progress);
} catch (NullReferenceException) {
    // Possible bug in PowerShell 7.4.0 leading to a null reference exception being thrown on ProgressPane completion
    // This is not happening on PowerShell 5.1
}

This issue affects all scripts that write to the console from multiple threads, leading to potential crashes in the LTS version of PowerShell. Affected users are forced to disable the progress bar either globally or per script.

Regression

  • Yes
  • No

[If yes, specify when the regression was introduced. Provide the PR or commit if known.]

Testing

[How was the fix verified? How was the issue missed previously? What tests were added?]

Risk

  • High
  • Medium
  • Low

[High/Medium/Low. Justify the indication by mentioning how risks were measured and addressed.]

…l#25440)

The WriteImpl() method should always be called within a lock on _instanceLock to ensure thread safety.
@TravisEz13 TravisEz13 added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label May 4, 2025
Copy link
Contributor

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label May 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Review - Needed The PR is being reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0