-
Notifications
You must be signed in to change notification settings - Fork 510
Powershell debugger hangs stepping over a script invocation #2742
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
Comments
Can you reproduce it with Preview version? |
Thanks @PrzemyslawKlys that's exactly what I would have asked! The preview extension is here: |
Yes, I found it in preview initially (most recently on 2020.6.0)... in fact, I think it's been there for several months. I went to production version to see if it was stable enough to not have this issue, so that's why I opened the bug with the release build. It took me some time to realize it, but I think I started seeing this issue a couple of months ago (preview builds). I was unable to narrow it down at the time, and chalked it up to preview instability. Most of my scripts do both set-strictmode and set ErrorActionPreference to Stop, so I was essentially unable to debug anything. Recently I've been working with more and more Pester scripts which do not apply both of these settings, and when debugging began to work I had thought the debugger was fixed. Once I realized that the bug has more to do with which scripts I'm debugging than which build of the powershell extension, I was able to zero in on a repro and open this issue. |
I actually tried it on my own and couldn't replicate your issue Set-StrictMode -Version 5
$ErrorActionPreference = "Stop"
. $PSScriptROot\test2.ps1
"hello 3" Had to use $PSScriptRoot because otherwise it would error. |
Good point. I assume this wouldn't have been necessary if you did Anyway, what's the next step? It reproduces 100% for me. Would a dump help? Maybe there is a clue in the logs. |
This might have something to do with it. From EditorServicesLog:
Does the powershell extension use pwsh or powershell? |
@johndog some next steps:
It looks like the log snippet you posted might be involved. It may be that strict mode prevents running something behind the scenes in the debugger. I did try to reproduce this just now on my Windows (10.0.19041) machine and wasn't able to in PowerShell 7.1, 7 or 5.1, so definitely worth trying the preview extension. Also worth determining if this always happens, or only sometimes.
It uses whichever of the PowerShells installed on your system you've got it configured to use. From your log snippet, this is currently PS 7.1 on your machine. You can change this by clicking on the little PowerShell icon/version in the lower right-hand corner of the VSCode window. |
@rjmholt - As mentioned above (link), I am using the latest extension. I only switched to release to see if it still reproduced. It doesn't seem to make a difference, and it reproduces 100% of the time. I'm on Windows 19635. Perhaps it regressed on some windows insider build along the way, since 19041.
I tried switching from 7.1 to 5.1 and it still reproduces. I'll follow the steps to collect diagnostic logs. |
Ah, sorry, I missed that. Yeah the logs should help, but if the issue becomes one that only reproduces in certain environments, our next step would be to collect a dump to work out where the code is |
This issue is being closed as inactive, if this issue is still occurring it will be re-opened |
@rjmholt This still reproduces for me.
Log messages pasted here still get printed: #2742 (comment) Which logs would be useful? What kind of dump would be useful? |
These logs seem to be the only relevant ones, so here they are in entirety... vscode-powershell.log:
EditorServices.log:
|
Thanks @johndog looks like the debugger may be having an issue with StrictMode |
$ErrorActionPreference being set to "stop" or "inquire" had the strange effect of making the debugger fail. I got this with Powershell and Powershell preview extension and thanks to this thread found this was the problem... really difficult bug to pinpoint because the debugger just stop responding during a debugging session but this code is still in debugging mode.. |
I have had this issue today as well. After looking at the log, I realized what caused it - at least in my case. In my case, I had a variable in the watch window, which wasn't initialized. For example, I can run the following script to produce the issue: Set-StrictMode -Version 2.0
$ErrorActionPreference = "Stop"
Write-Host "Hello World" I can set a breakpoint on the first line and step through the script. As soon as I've stepped over the first two lines and try to step to the StrictMode version 1.0 and onwards lists the following:
So I guess setting any version of StrictMode combined with Here's what I saw in my log that helped me spot the issue:
It would be nice to have a fix for this. It would be great for the watch to check if the variable exists first, and if not, just write something like |
I had something similar while using interactive debugging. Debugger works but interactive terminal hangs and I can't type any word in it. It's basically dead. The connection with this thread is the OS: Logs from Editor Services:
$PSVersionTable:
VS Code: ms-vscode.powershell: |
An update. The issue is with watches like in @oliverroer post. I'm getting:
I have 3 watches set that values aren't defined in the script I debug: |
We'll come back to this when the debugger implementation is revamped (in PowerShell/PowerShellEditorServices#1295). |
I tried to reproduce this which was straight forward. I noticed that the console has a debug prompt. Typing 'c' allowed the script to continue. In this sense it is similar to the issue I raised 'PowerShell debugger hangs using F10 (#3410)'. |
This is not a bad idea at all, I'll see what I can do. |
I have been struggling with debugging scripts for some time. This fix saved the day. |
@alvicstep As the most recent person to encounter this, can I ask you if it reproduces with the Preview extension still? |
The extension version i am currently using is v2021.12.0
Last updated: 12/22/2021 13:56:27
Debugging did not work untill i removed a watched variable which did not
exist.
Thank you
…On Wed, Jan 5, 2022 at 3:32 PM Andy Schwartzmeyer ***@***.***> wrote:
@alvicstep <https://github.com/alvicstep> As the most recent person to
encounter this, can I ask you if it reproduces with the Preview extension
still?
—
Reply to this email directly, view it on GitHub
<#2742 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEY7SXZDXDUUM6MW5ERIGILUUTIJXANCNFSM4NR2NM6A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Could you try the Preview extension? |
I switched to preview.
I can still debug with watched variable which does not exist.
Thanks
…On Wed, Jan 5, 2022 at 4:13 PM Andy Schwartzmeyer ***@***.***> wrote:
Could you try the Preview extension?
—
Reply to this email directly, view it on GitHub
<#2742 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEY7SX7QHBFT7AZXHNHX77DUUTNC7ANCNFSM4NR2NM6A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Fantastic, thank you for the confirmation @alvicstep! |
This issue has been marked as fixed. It has been automatically closed for housekeeping purposes. |
Issue Type: Bug
Result: debugger will never return. You have to stop it and restart the integrated powershell instance.
Note: If either of the first two lines are commented out, i.e. without either Set-StrictMode OR $EAP = "Stop", it seems to work The combination causes fits.
Note 2: If there are no breakpoints, it seems to work then as well.
Extension version: 2020.4.0
VS Code version: Code 1.45.1 (5763d909d5f12fe19f215cbfdd29a91c0fa9208a, 2020-05-14T08:27:35.169Z)
OS version: Windows_NT x64 10.0.19635
System Info
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled
The text was updated successfully, but these errors were encountered: