Skip to content

Debug adapter process terminated unexpectedly and PowerShell session has terminated due to an error at the same time and all time #1078

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

Closed
Cognic opened this issue Oct 30, 2017 · 20 comments
Assignees

Comments

@Cognic
Copy link

Cognic commented Oct 30, 2017

System Details

  • Operating system name and version: Windows Server 2016, Version 1607
  • VS Code version: 1.17.2
  • PowerShell extension version: 1.5.0
  • Output from $PSVersionTable:
    Name Value

PSVersion 5.1.14393.1532
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.1532
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1



code -v : 
1.17.2
b813d12980308015bcd2b3a2f6efa5c810c33ba5

$pseditor.EditorServicesVersion:
Major  Minor  Build  Revision
-----  -----  -----  --------
1      5      0      0

code --list-extensions --show-versions:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

$PSVersionTable:
Name                           Value                                                                                                                                     
----                           -----                                                                                                                                     
PSVersion                      5.1.14393.1532                                                                                                                            
PSEdition                      Desktop                                                                                                                                   
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                   
BuildVersion                   10.0.14393.1532                                                                                                                           
CLRVersion                     4.0.30319.42000                                                                                                                           
WSManStackVersion              3.0                                                                                                                                       
PSRemotingProtocolVersion      2.3                                                                                                                                       
SerializationVersion           1.1.0.1 

Issue Description:

"Debug adapter process has terminated unexpectedly"
"The PowerShell session has terminated due to an error, would you like to restart"

These two errors keeps popping up every time I run something from VScode, not even while debugging.
VSCode has been my primary editor for long but these days its very annoying to keep switching between VSCode for writing and ISE for debugging and running. Please fix.

Attached Logs

logs.zip

@ZHumphries
Copy link

I get exactly the same error when attempting to attach to a powershell process to debug.

@Halkcyon
Copy link

Halkcyon commented Nov 2, 2017

Same VSCode and extension versions. PowerShell debugging does not work. No output to the debug console, session crashes constantly. Completely useless for debugging still. It's a bit frustrating to have to go back to the ISE to properly test anything.

@rkeithhill
Copy link
Contributor

rkeithhill commented Nov 5, 2017

I see what the problem is here. I believe we can get this fixed for the next drop. BTW the problem pointed out by the log for this issue is the existence of an 'Untitled" editor window open in the workspace. If there is a breakpoint set in an unsaved file, we can't break on it. The PowerShell debug engine requires a filename and a line number. And even before it gets to that point, path handling code chokes on "untitled:Untitled-3".

@rkeithhill rkeithhill self-assigned this Nov 5, 2017
@rkeithhill
Copy link
Contributor

I was puzzled how to repro this. Finally figured it out. If you diff a PS1 file and then in the diff viewer, set a breakpoint in the right pane, a breakpoint of the form Untitled-X will show up in the breakpoints view. We can't set a line breakpoint unless we have a full file path. So long story short, we'll fix the crash but breakpoints set in the right pane of the Git diff viewer will not work.

@Cognic
Copy link
Author

Cognic commented Nov 7, 2017

Thanks Keith for picking it up. I have closed the untitled-X file and opened a saved script and tried to debug and its still the same error. Thought of letting you know. Thanks.

@rkeithhill
Copy link
Contributor

Can you attach the zipped log file for such a session?

@MRWeather
Copy link

If you set a breakpoint in a non-saved file, then close that file without saving, the breakpoint remains in the breakpoint list and the debugger crashes. Even disabling the Untitled-x breakpoint causes the debugger to crash. If you remove all breakpoints and add a breakpoint to a saved file, the debugger works as expected.
Seems like it should either prevent breakpoints on unsaved files (since they don't seem to work anyway) or remove any breakpoints on unsaved files when the file is closed and not saved. $.02

@rkeithhill
Copy link
Contributor

@MRWeather I believe I have that particular crash fixed. I think @Cognic is running into a different bug now but hard to tell unless I can get the log files.

@MRWeather
Copy link

OK. It sounded the same to me - for me it wasn't the open unsaved file, but a breakpoint for any unsaved file that was causing the problem. If @Cognic had a breakpoint for an unsaved file, closing the file and opening a different one without removing the bad breakpoint would not do anything.

Either way, thanks for working on this - I hope you get lots of appreciation :)

@rkeithhill
Copy link
Contributor

No worries. Glad to have to the extra info!

@Cognic
Copy link
Author

Cognic commented Nov 8, 2017

@rkeithhill Attached the logs. Thanks.

logs_v1.zip

@ZHumphries
Copy link

for me its reproducible by simply opening a clean install of VSCode and attaching the debugger to an external powershell process. (Without opening any files/directories first)

@rkeithhill
Copy link
Contributor

@ZHumphries That is a different bug related to debugging that is being tracked here

@rkeithhill
Copy link
Contributor

@Cognic This looks to be the exact same issue as before:

11/8/2017 10:10:13 AM [VERBOSE] - Method "ReadMessage" at line 123 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Protocol\MessageProtocol\MessageReader.cs

    Received Request 'setBreakpoints' with id 3

11/8/2017 10:10:13 AM [VERBOSE] - Method "ResolveFilePath" at line 354 of C:\projects\powershelleditorservices\src\PowerShellEditorServices\Workspace\Workspace.cs

    Resolved path: untitled:Untitled-3

11/8/2017 10:10:13 AM [ERROR] - Method "OnListenTaskCompleted" at line 391 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs

    ProtocolEndpoint message loop terminated due to unhandled exception:
    
    System.AggregateException: One or more errors occurred. ---> System.NotSupportedException: The given path's format is not supported.
       at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
       at Microsoft.PowerShell.EditorServices.Workspace.GetFile(String filePath)
       at Microsoft.PowerShell.EditorServices.Protocol.Server.DebugAdapter.<HandleSetBreakpointsRequest>d__25.MoveNext()

I wonder if you're seeing what @MRWeather points out above. That is, you don't have an "Untitled-3" window open but at some point you did and you set a breakpoint in it and closed that window. But the breakpoint hung around. If you look in the Breakpoints view, do you see a breakpoint set on "Untitled-3"? If so, right-click and remove that breakpoint. That should get you debugging again.

@Cognic
Copy link
Author

Cognic commented Nov 9, 2017

@rkeithhill Sorry I forgot to mention that I have tried what @MRWeather pointed out and didn't work.
Now there was a new version got pushed 1.18.0 which seems to have fixed the debugging issue. Thank you.

@rkeithhill
Copy link
Contributor

rkeithhill commented Nov 9, 2017

Ah, looks like they fixed the VSCode side of the debugger. I'm still going to commit my changes to make the PowerShell side more resilient to this.

@MRWeather
Copy link

The breakpoint on an unsaved file is still an issue for me even with the new VSCode.

@rkeithhill
Copy link
Contributor

I believe this particular issue has been fixed. If I haven't heard otherwise in a few days, I'm going to close this issue.

@MRWeather
Copy link

I believe it is fixed. I have tested the conditions that I reported and the debugger doesn't crash.

I still think it is odd that you can set a breakpoint in an unsaved file when it won't break on it. And if you save after setting a breakpoint, the Untitled-x breakpoint remains in the list of breakpoints.
I know these warrant another issue.
So the symptom is fixed, I have no problem with this issue being closed.

@rkeithhill
Copy link
Contributor

rkeithhill commented Dec 7, 2017

@MRWeather Thanks for following up. Yeah, there are some oddities with the interaction (or lack thereof) between the VSCode debug breakpoint UI and the target debugger - which doesn't actually get invoked until the user starts debugging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants