Skip to content

Attaching to a process that has the .NET debugger disabled fails with "Unknown Error: 0x80131c08" and does not name the cause #9838

Open

Description

@pcshrosbree

Summary

If the target process was started with DOTNET_EnableDiagnostics_Debugger=0 (or DOTNET_EnableDiagnostics=0), attaching from VS Code fails with:

Unable to start debugging. Failed to attach to process: Unknown Error: 0x80131c08

0x80131c08 is CORDBG_E_TIMEOUT ("A wait timed out, likely an indication of deadlock"). The message does not say that the target has its debugger switched off, and "deadlock" points the reader elsewhere. The switch is a documented hardening setting. A developer who meets this error on a process configured by someone else has no route from the message to the cause.

Environment

  • VS Code 1.140.0, C# extension 2.160.4 (vsdbg as bundled with that extension), Linux x64 (Ubuntu 26.04.1)
  • Target runtimes: official .NET 10.0.12 and 8.0.31, linux-x64

Steps to reproduce

  1. Create an app that stays alive long enough to attach to:

    Console.WriteLine($"pid {Environment.ProcessId}");
    Thread.Sleep(TimeSpan.FromMinutes(2));
    
  2. Start it with the runtime's debugger disabled:

    DOTNET_EnableDiagnostics_Debugger=0 dotnet run
    
  3. In VS Code, start a coreclr attach configuration ("request": "attach", "processId": "${command:pickProcess}") and pick the process.

Expected behavior

A message that names the likely cause. For example: "The target process is not accepting debugger connections. It may have been started with DOTNET_EnableDiagnostics=0 or DOTNET_EnableDiagnostics_Debugger=0, or it may use a different temporary directory from the debugger (TMPDIR, systemd PrivateTmp)." Failing that, at least the symbolic name CORDBG_E_TIMEOUT.

Actual behavior

Unable to start debugging. Failed to attach to process: Unknown Error: 0x80131c08. The target keeps running, unaffected.

What I measured

  • vsdbg (this extension): the message above, about 10 s after F5, attaching to a plain console app with no other tooling loaded, started with DOTNET_EnableDiagnostics_Debugger=0 on .NET 10.0.12. The same app started without the switch attached normally. The same message also appeared on .NET 8.0.31, in a setup where a profiling tool was also loaded in the target.

  • The runtime side. A checked runtime build logs Debugging disabled via EnableDiagnostics_Debugger config. once at start-up, and the debugger transport is never created. On Linux the transport's FIFOs are missing from $TMPDIR while the diagnostics IPC socket is still there:

    no switch:  clr-debug-pipe-<pid>-<key>-in, clr-debug-pipe-<pid>-<key>-out, dotnet-diagnostic-<pid>-<key>-socket
    switch set: dotnet-diagnostic-<pid>-<key>-socket only
    
  • Another debugger, for comparison. netcoredbg 3.2.0, attaching to the same kind of app with no other tooling loaded, fails configurationDone with 0x80131c08 after 10.0 s (3/3). The control without the switch attaches in under 0.1 s (3/3). So the HRESULT comes from the runtime's debugging services, not from vsdbg.

Suggestion

  1. Decode the HRESULT to its symbolic name rather than "Unknown Error".
  2. On Linux and macOS, when an attach to a .NET process times out, check whether the target's debugger transport exists (clr-debug-pipe-<pid>-* in the temp directory). If it is missing while the process is clearly a .NET process (its dotnet-diagnostic-<pid>-* socket exists, or libcoreclr is mapped), say that the target is not accepting debugger connections and name the two likely causes: the EnableDiagnostics switches, and a temp-directory mismatch (Error 0x80131c08 when attaching debugger to systemd process that uses PrivateTmp=true #3277).
  3. Optionally, make that check before the attach and fail fast rather than after the timeout.

Related: #3277 (same error, temp-directory cause; a better error was suggested there) and #6883 (the same switch on the launch route, which failed silently).

Activity

  1. gregg-miskelly commented on Oct 1, 2026

    @gregg-miskelly
    Contributor

    Seems reasonable, but this will need a change from the .NET Runtime's debugging services.

  2. pcshrosbree commented on Oct 2, 2026

    @pcshrosbree
    Author

    Thanks, agreed. I traced it, and the debugger component that ships with the runtime (mscordbi) sees the specific failure and then discards it:

    1. TwoWayPipe::Connect opens the target's clr-debug-pipe-<pid>-<key>-in FIFO. A target started with the switch never creates it, so open() fails with ENOENT, and Connect returns false without keeping the errno (src/coreclr/debug/debug-pal/unix/twowaypipe.cpp).
    2. On main, ConnectToChannel reports any Connect failure as E_OUTOFMEMORY. The transport worker then treats it as "no listener", sleeps 1 s and retries. The code carries a TODO for exactly this: "not really sure that this is the real failure … we probably need to analyse GetErrorCode() here" (src/coreclr/debug/shared/dbgtransportsession.cpp).
    3. DbgTransportPipeline::DebugActiveProcess waits 10 s for the session to open and then returns CORDBG_E_TIMEOUT (src/coreclr/debug/di/dbgtransportpipeline.cpp). That matches the 10 s I measured.

    I've opened dotnet/runtime#135113 asking for that reason to be kept and returned as a distinct HRESULT.

    Two questions, so that this issue can track the vsdbg side:

    1. Once the runtime returns a distinct HRESULT for this case, would vsdbg show that HRESULT's message rather than "Unknown Error"?
    2. Separately, is decoding a CORDBG_E_* HRESULT to its symbolic name in scope here? That part does not depend on a runtime change.
  3. gregg-miskelly commented on Oct 2, 2026

    @gregg-miskelly
    Contributor
    1. Once the runtime returns a distinct HRESULT for this case, would vsdbg show that HRESULT's message rather than "Unknown Error"?

    No, vsdbg will have a tiny amount of work to map that error code to a string

    1. Separately, is decoding a CORDBG_E_* HRESULT to its symbolic name in scope here? That part does not depend on a runtime change.

    We have attempted to decode the various CORDBG_E_* HRESULTs with a useful meaning that makes it back to the user. But, for example here, I don't think showing CORDBG_E_TIMEOUT is actually all that helpful. If you see any others, happy to add decoding.

  4. pcshrosbree commented on Oct 2, 2026

    @pcshrosbree
    Author

    Thanks, that's clear. The runtime change is up as dotnet/runtime#135114. It adds CORDBG_E_DEBUGGER_TRANSPORT_NOT_FOUND (0x80131c6a), which mscordbi returns from DebugActiveProcess when the attach times out because the target's clr-debug-pipe-<pid>-<key>-in does not exist. Its message is:

    The debugger could not find the target process's debugger transport. The process may have been started with DOTNET_EnableDiagnostics=0 or DOTNET_EnableDiagnostics_Debugger=0, or the debugger and the process may use different temporary directories.

    If it merges, mapping that code to that message is the vsdbg side of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions