Skip to content

Binary Module Debugging with Script specified causes a terminal error exit -1 at the end of the debugging session on Windows only #4702

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
5 of 6 tasks
ALIENQuake opened this issue Aug 16, 2023 · 18 comments · Fixed by #4704
Assignees
Labels

Comments

@ALIENQuake
Copy link

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

I'm getting a crash when I attempt to debug the binary module using a new configuration. The module is the not altered example binary module.

        {
            "name": "PowerShell: Binary Module Interactive",
            "type": "PowerShell",
            "request": "launch",
            "script": "Import-Module -Force ${workspaceFolder}/DebugPSModule/bin/Debug/net8.0/DebugPSModule.dll",
            "createTemporaryIntegratedConsole": true,
            "attachDotnetDebugger": true
          }

Launching test script works: Test-SampleCmdlet -FavoriteNumber 8 -FavoritePet Dog

VERBOSE: Begin!

VERBOSE: End!
FavoriteNumber FavoritePet
-------------- -----------
             8 Dog

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.4.0-preview.4
PSEdition                      Core
GitCommitId                    7.4.0-preview.4
OS                             Microsoft Windows 10.0.23521
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

Version: 1.81.1
Commit: 6c3e3dba23e8fadc360aed75ce363ba185c49794
Date: 2023-08-09T22:22:42.175Z
Electron: 22.3.18
ElectronBuildId: 22689846
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.23521

Extension Version

PowerShell Extension v2023.6.0
C# Dev Kit v0.3.21
NET Install Tool for Extension Authors v1.7.0
Inline Values support for PowerShell v0.0.7

Steps to Reproduce

  • Hit F5

Visuals

No response

Logs

logs.zip
sessions.zip

@ALIENQuake ALIENQuake added the Issue-Bug A bug to squash. label Aug 16, 2023
@andyleejordan
Copy link
Member

/cc @JustinGrote

@JustinGrote
Copy link
Collaborator

@ALIENQuake what kind of "crash"? Full system crash? vscode crash? Can you use a tool like screen2gif or zoomit to record what happens?

The process just triggers the omnisharp debugger so anything that would make that crash would make this crash.

@ALIENQuake
Copy link
Author

@JustinGrote His is how it looks at my side:

explorer_RMJOMJBc59.mp4

@JustinGrote
Copy link
Collaborator

@ALIENQuake I see an F: drive in use here. Is this a local drive or a network share?

@ALIENQuake
Copy link
Author

@JustinGrote All drives are local ones.

@JustinGrote
Copy link
Collaborator

Also according to the logs, your import module resolves to Import-Module -Force C:\\Users\\ALIEN\\Desktop\\a1/DebugPSModule/bin/Debug/net8.0/DebugPSModule.dll which may not be correct? What does your debug config look like?

@ALIENQuake
Copy link
Author

ALIENQuake commented Aug 16, 2023

@JustinGrote The path to the dll is correct as I'm able to import it before launching Test-SampleCmdlet. This is my launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "PowerShell: Launch Current File",
            "type": "PowerShell",
            "request": "launch",
            "script": "${file}",
            "args": []
        },
        {
            "name": "PowerShell: Binary Module Interactive",
            "type": "PowerShell",
            "request": "launch",
            "script": "Import-Module -Force ${workspaceFolder}\\DebugPSModule\\bin\\Debug\\net8.0\\DebugPSModule.dll",
            "createTemporaryIntegratedConsole": true,
            "attachDotnetDebugger": true
        }
    ]
}
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          16.08.2023    20:56                .vscode
d----          16.08.2023    21:21                DebugPSModule
-a---          16.08.2023    20:36            202 a1.ps1
-a---          16.08.2023    19:16            307 a2.ps1
-a---          16.08.2023    20:31            862 a3.ps1
-a---          04.08.2023    19:44            225 F8Debuging.ps1
-a---          16.08.2023    23:27            186 test.ps1
-a---          04.08.2023    21:35            376 zzz.txt

@JustinGrote
Copy link
Collaborator

OK, I'm seeing this too, I think it may have something to do with the major 2.0 C# update.

@JustinGrote JustinGrote self-assigned this Aug 16, 2023
@JustinGrote
Copy link
Collaborator

So the command and debug session itself work fine, I just think when the pwsh process ends, it's not being handled correctly. You shouldn't have any problem debugging in-and-of-itself, this looks to just be a cosmetic cleanup thing, thanks for reporting!

image

@JustinGrote
Copy link
Collaborator

@andyleejordan is there anything in PSES that would cause it to exit -1?

@ALIENQuake
Copy link
Author

@JustinGrote I still can't debug anything. I simply want to recreate the debugging experience that you have presented at #3903 but no matter what I do, I'm getting crash and debugged doesn't stop at the .cs file breakpoints.

@andyleejordan
Copy link
Member

@andyleejordan is there anything in PSES that would cause it to exit -1?

Not that I can think of!

@JustinGrote
Copy link
Collaborator

JustinGrote commented Aug 17, 2023

@ALIENQuake debugging and breakpoints work just fine for me with the PowerShell standard example, I can't reproduce:
image

@ALIENQuake
Copy link
Author

I confirm that debugging works, thumbs up for resolving remaining error.

@JustinGrote JustinGrote changed the title I'm getting a crash when I attempt to debug the binary module using a new configuration. Binary Module Debugging with Script specified causes a terminal error exit -1 at the end of the debugging session Aug 17, 2023
@JustinGrote
Copy link
Collaborator

JustinGrote commented Aug 17, 2023

@ALIENQuake glad to hear, I'm going to retitle this issue and reuse it for solving the terminal error

@JustinGrote JustinGrote changed the title Binary Module Debugging with Script specified causes a terminal error exit -1 at the end of the debugging session Binary Module Debugging with Script specified causes a terminal error exit -1 at the end of the debugging session on Windows only Aug 17, 2023
@JustinGrote
Copy link
Collaborator

The problem is that the attach being stopped actually kills the process rather than disconnecting, but there doesn't appear to be an extension api to initiate a disconnect, so this is blocked on:
microsoft/vscode-discussions#767

@andyleejordan
Copy link
Member

Thanks for debugging @JustinGrote!

@ALIENQuake
Copy link
Author

@JustinGrote Thank you!

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