-
Notifications
You must be signed in to change notification settings - Fork 511
Debugging with active breakpoint crashes Powershell session #3667
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
Debugging with active breakpoint crashes Powershell session #3667
Comments
@JustinGrote Can you repro this? Would've expected you to hit this bug while troubleshooting #3655, unless it's a local problem. |
I can consistently reproduce if you:
I get the same scopes issue. Doesn't happen if you don't have a debug session started. |
Definitely some debugging issues to work through... |
Full stacktrace of being able to reproduce it, I'm pretty sure whatever the problem is happens before this point. I'll try to get a debug session going.
|
This part of the fetching of stack frames is the problem, the i loop goes to an undefined scope. |
Fails here, tries to do a |
This doesn't account for a scope exception. Adding a try catch to swallow that specific exception here should have the expected result, at least unless we can find a more proactive way to determine if variables exist without having to run a command. Any advice @rjmholt @SeeminglyScience for how we can know ahead of time if a stackframe has local variables? |
This is a pretty old issue (#1856) though in the past it just polluted In the PR for the rewrite I made a comment about us setting |
Some details about why this error occurs in general in this comment. |
This does look exactly what it is #1856 (comment) |
Yeah it comes up from time to time. I think the real problem is that a benign error is causing a crash. Ideally it would be a silent non-terminating error, but at the very least there's a catch somewhere that's too specific. |
Agreed, @andschwa there should be a broad catch for all otherwise-uncaught pwsh invocation exceptions that logs the exception occurred but doesn't kill PSES (or at the very worst auto-restarts it) |
Ah right parameter binding exceptions are terminating so not |
Draft Fix: PowerShell/PowerShellEditorServices#1620 |
I think it might need to just be here. Maybe change the |
Makes sense, @andschwa this should be a separate PR and it has wide reaching consequences so I'd ask you try this part :) |
Prerequisites
Summary
Powershell session crashes in preview extension when attempting to debug a script with active breakpoint in unsaved file. Debugging the same code in a saved file works.
Also occurs when debugging Pester tests, but was able to reproduce the same exception in this simpler demo so I believe it might be the same root cause.
PowerShell Version
Visual Studio Code Version
Extension Version
[email protected]
Steps to Reproduce
$a = 1
Visuals
Repro

Exception

Logs
No response
The text was updated successfully, but these errors were encountered: