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

Using Debug-Job to debug a background / thread job causes a crash #3954

Closed
3 tasks done
mklement0 opened this issue Feb 21, 2024 · 0 comments · Fixed by #3957
Closed
3 tasks done

Using Debug-Job to debug a background / thread job causes a crash #3954

mklement0 opened this issue Feb 21, 2024 · 0 comments · Fixed by #3957
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation.

Comments

@mklement0
Copy link

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

VERBOSE: Waiting for job to be in the 'Running' state...
VERBOSE: Starting debugging...
At line:2 char:10
+   while ($true) { Start-Sleep -Milliseconds 100 }
+          ~~~~~
[DBG]: [Job12]: PS /Users/jdoe>>
Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
Thank you!

### Environment
PSReadLine: 2.3.4
PowerShell: 7.5.0-preview.1
OS: Darwin 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000
BufferWidth: 180
BufferHeight: 60

Last 33 Keys:

 p g Enter
 p g Enter
 p g Enter
 p g Enter
 g j b Enter
 g m o Enter
 p g Enter
 p g Enter
 c l r Enter
 p g Enter


### Exception

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.PowerShell.PSConsoleReadLine.UpdatePredictionClient(Runspace runspace, EngineIntrinsics engineIntrinsics)
   at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics)
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)

Screenshot

N/A

Environment data

PS Version: 7.5.0-preview.1
PS HostName: ConsoleHost
PSReadLine Version: 2.3.4
PSReadLine EditMode: Emacs
OS: Darwin SomeMachine.local 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64
BufferWidth: 180
BufferHeight: 60

Steps to reproduce

$jb = Start-ThreadJob {
  while ($true) { Start-Sleep -Milliseconds 100 }
}

try {

  Write-Verbose -Verbose 'Waiting for job to be in the ''Running'' state...'
  while ($jb.State -notin  'Running') { Start-Sleep -Milliseconds 100 }

  Write-Verbose -Verbose 'Starting debugging...'
  $jb | Debug-Job

}
finally {
  if ($jb) { $jb | Remove-Job -Force }
}

Expected behavior

The debugger should be entered and behave normally.

Actual behavior

PSReadLine crashes with the output above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants