Skip to content
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

Fix the null-reference exception when running Debug-Job on a thread job #3957

Merged
merged 1 commit into from Feb 26, 2024

Conversation

daxian-dbw
Copy link
Member

@daxian-dbw daxian-dbw commented Feb 26, 2024

PR Summary

Fix #3954

The $Host.Runspace is null when PSConsoleHostReadLine is invoked while debugging a thread job.
This is because a thread job uses the default host, which always has value null for $Host.Runspace.
We set the current path to be null when either runspace or engineIntrinsics is null.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure you've added one or more new tests
  • Make sure you've tested these changes in terminals that PowerShell is commonly used in (i.e. conhost.exe, Windows Terminal, Visual Studio Code Integrated Terminal, etc.)
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed at PowerShell-Docs
      • Doc Issue filed:
Microsoft Reviewers: Open in CodeFlow

PSReadLine/Prediction.cs Show resolved Hide resolved
@daxian-dbw daxian-dbw merged commit ce2302c into PowerShell:master Feb 26, 2024
2 checks passed
@daxian-dbw daxian-dbw deleted the null-ex branch February 26, 2024 21:29
@daxian-dbw daxian-dbw added Backport-2.3.x-Consider To be backported to v2.3.x. Backport-2.3.x-Done Finished cherry-picking the commit to the release branch. and removed Backport-2.3.x-Consider To be backported to v2.3.x. labels Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport-2.3.x-Done Finished cherry-picking the commit to the release branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using Debug-Job to debug a background / thread job causes a crash
2 participants