dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.85k stars 667 forks source link

Upgrading to .NET core 2.1 or higher makes the vbdbg to fail on attaching #3795

Open jfalameda opened 4 years ago

jfalameda commented 4 years ago

Prerequisites:

  1. App running on docker contained Service fabric cluster on Ubuntu 16.04
  2. Previously it worked to debug .net 2.0 apps via piperProgram: docker
  3. Upgrading to a .net core version higher than 2.2 makes the debugger to fail to attach.
 {
            "name": ".NET Core Docker Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:pickRemoteProcess}",
            "pipeTransport": {
                "pipeProgram": "docker",
                "pipeArgs": [ "exec",  "-u", "sfappsuser", "-i", "dhcloud_sfcluster_1" ],
                "debuggerPath": "/vsdbg/vsdbg",
                "pipeCwd": "${workspaceRoot}",
                "quoteArgs": false
            },
            "logging": {
                "engineLogging": true
            },
            "requireExactSource": false
        },

Logs

{"seq":9,"type":"response","request_seq":6,"success":false,"command":"configurationDone","message":"Failed to attach to process: Unknown Error: 0x80131c08"}
gregg-miskelly commented 4 years ago

This is a problem with the .NET Runtime's IPC mechanism. It is failing with CORDBG_E_TIMEOUT.

Are you by chance using a private temp directory for the app you are trying to debug? See https://github.com/OmniSharp/omnisharp-vscode/issues/3277

jfalameda commented 4 years ago

Hi Gregg,

We are not using a private directory, as far as I know, our project is using Service Fabric and I am not completely aware of how it handles the processes. We tried what you suggest on #3277 but we could not find anything.

This only happens with versions higher than 2.1. Otherwise, the debugger works fine.

Do you have any other clues?

In order to debug, create a SF cluster on Linux, and try to attach to a 3.1 .NET core.

tejasavora commented 4 years ago

I have been having the same problem. I am trying to attach to Service Fabric Application. OS: Ubuntu 18.04.4 LTS OmniSharp: 1.22.1 DotNet: 3.1.301 SF: 7.1

While trying to attach to service from VS code, it is giving an error: 0x80131c08 I am running VS Code as a elevated privileges under sudo and it is using its own private user data directory.

Output from vsdbg-ui

Waiting for communication on port 4711...
>> accepted connection from client
-> (C) {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"coreclr","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true},"type":"request","seq":1}
<- (R) {"seq":0,"type":"response","request_seq":1,"success":true,"command":"initialize","message":"","body":{"supportsConfigurationDoneRequest":true,"supportsFunctionBreakpoints":false,"supportsConditionalBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsEvaluateForHovers":true,"exceptionBreakpointFilters":[{"filter":"all","label":"All Exceptions","default":false},{"filter":"user-unhandled","label":"User-Unhandled Exceptions","default":true}],"supportsSetVariable":true,"supportsGotoTargetsRequest":true,"supportsModulesRequest":true,"additionalModuleColumns":[],"supportedChecksumAlgorithms":["MD5","SHA1","SHA256"],"supportsExceptionOptions":true,"supportsValueFormattingOptions":true,"supportsExceptionInfoRequest":true,"supportTerminateDebuggee":true,"supportsSetExpression":true,"supportsReadMemoryRequest":true,"supportsExceptionConditions":true,"supportsLoadSymbolsRequest":true,"supportsModuleSymbolSearchLog":true,"supportsDebuggerProperties":true,"supportsSetSymbolOptions":true}}
-> (C) {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"coreclr","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true},"type":"request","seq":1}
-> (C) {"command":"attach","arguments":{"name":".NET Core Attach","type":"coreclr","request":"attach","processId":"6352","logging":{"engineLogging":false},"debugServer":4711,"__sessionId":"107ce00b-afc0-40f9-bbc4-eb86c7786acb"},"type":"request","seq":2}
<- (E) {"seq":3,"type":"event","event":"output","body":{"category":"console","output":"-------------------------------------------------------------------\nYou may only use the Microsoft .NET Core Debugger (vsdbg) with\nVisual Studio Code, Visual Studio or Visual Studio for Mac software\nto help you develop and test your applications.\n-------------------------------------------------------------------\n"}}
<- (R) {"seq":4,"type":"response","request_seq":2,"success":true,"command":"attach"}
<- (E) {"seq":5,"type":"event","event":"initialized","body":{}}
-> (C) {"command":"setExceptionBreakpoints","arguments":{"filters":["user-unhandled"]},"type":"request","seq":3}
<- (R) {"seq":6,"type":"response","request_seq":3,"success":true,"command":"setExceptionBreakpoints"}
-> (C) {"command":"configurationDone","type":"request","seq":4}
<- (E) {"seq":7,"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/vsdbg/AttachFailed","data":{"VS.Diagnostics.Debugger.vsdbg.ErrorCode":-2146231288,"VS.Diagnostics.Debugger.vsdbg.Distribution.Name":"ubuntu","VS.Diagnostics.Debugger.vsdbg.Distribution.Version":"18.04","VS.Diagnostics.Debugger.vsdbg.OSFamily":"Linux","VS.Diagnostics.Debugger.vsdbg.Version":"16.6.20415.1 commit:0184bb70e1ed40656c0dfa53125805036207007b"}}}
<- (R) {"seq":8,"type":"response","request_seq":4,"success":false,"command":"configurationDone","message":"Failed to attach to process: Unknown Error: 0x80131c08"}
-> (C) {"command":"disconnect","arguments":{"restart":false},"type":"request","seq":5}
-> (C) {"command":"threads","type":"request","seq":6}
<- (E) {"seq":9,"type":"event","event":"output","body":{"category":"telemetry","output":"VS/Diagnostics/Debugger/vsdbg/DebugCompleted","data":{"VS.Diagnostics.Debugger.vsdbg.AdapterId":"coreclr","VS.Diagnostics.Debugger.vsdbg.DebugCompleted.BreakCounter":0,"VS.Diagnostics.Debugger.vsdbg.Distribution.Name":"ubuntu","VS.Diagnostics.Debugger.vsdbg.Distribution.Version":"18.04","VS.Diagnostics.Debugger.vsdbg.OSFamily":"Linux","VS.Diagnostics.Debugger.vsdbg.Version":"16.6.20415.1 commit:0184bb70e1ed40656c0dfa53125805036207007b"}}}
<- (R) {"seq":10,"type":"response","request_seq":5,"success":true,"command":"disconnect"}
>> client connection closed

Is there a work around we can use to unblock from this issue?

jfalameda commented 4 years ago

For me all of a sudden a couple of weeks ago it started working. Have you tried updating vsdbg to the latest version?