Skip to content

Add configurable debuginfod settings to prevent GDB hangs#1561

Open
WardenGnaw wants to merge 2 commits into
mainfrom
dev/waan/fixDebugInfod
Open

Add configurable debuginfod settings to prevent GDB hangs#1561
WardenGnaw wants to merge 2 commits into
mainfrom
dev/waan/fixDebugInfod

Conversation

@WardenGnaw
Copy link
Copy Markdown
Member

Why is this change being made?

Fixes microsoft/vscode-cpptools#14458

MIEngine commit f169b02 added set debuginfod enabled on unconditionally in GetInitializeCommands(). On systems where DEBUGINFOD_URLS points to an unreachable server (e.g. debuginfod.ubuntu.com which is currently down), subsequent GDB commands block for 90+ seconds waiting for the network request to time out, causing GDB to appear hung on launch.

Summarize what changed

  • Added a debuginfod launch option (JSON: { enabled: bool, timeout: int } XML: EnableDebuginfod/DebuginfodTimeout attributes) defaulting to enabled with a 30-second timeout.
  • When enabled (timeout > 0): sets DEBUGINFOD_TIMEOUT and DEBUGINFOD_MAXTIME environment variables on the GDB process to cap network requests.
  • When enabled (timeout = 0): no timeout override is applied; GDB/libdebuginfod defaults are used.
  • When disabled: clears DEBUGINFOD_URLS on the GDB process so debuginfod connections are never attempted, even if the system has the env var set.
  • set debuginfod enabled on is now conditional on the EnableDebuginfod setting.
  • Added XSD schema validation (minInclusive=0) and JSON schema (minimum: 0).
  • Negative timeout values are clamped to the default (30) at runtime.

How was the change tested?

  • Changes reviewed by Copilot CLI (using /review)
  • All 36 MICoreUnitTests pass
  • Integration tests (DebuginfodTests) pass in WSL with GDB 12.1: - DebuginfodDisabledDoesNotHang: steps into std::regex with unreachable server, verifies launch completes in < 10s - DebuginfodTimeoutPreventsHang: steps into std::regex with 5s timeout, verifies launch completes in < 30s
  • All existing CppTests pass (Sample, Execution, Breakpoint, Environment)
  • Verified via TCP listener that debuginfod URLs are actually queried during step-into-library operations

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a configurable debuginfod launch option to control GDB’s debuginfod behavior (enable/disable + request timeout) to prevent long hangs when DEBUGINFOD_URLS points to unreachable servers.

Changes:

  • Added new launch options/schemas for debuginfod (JSON + XML/XSD) with validation and runtime clamping of negative timeouts.
  • Updated MIEngine initialization to only enable debuginfod when configured, and updated local process launch to apply debuginfod-related environment variables.
  • Added new integration tests + a dedicated debuggee to validate “disabled” and “timeout” scenarios.
Show a summary per file
File Description
test/CppTests/Tests/DebuginfodTests.cs Adds integration tests validating debuginfod disable/timeout prevents hangs.
test/CppTests/Tests/DebuggeeMonikers.cs Adds a moniker for the new debuginfod debuggee.
test/CppTests/OpenDebug/CrossPlatCpp/LaunchCommand.cs Extends test launch args to support debuginfod and setupCommands.
test/CppTests/debuggees/debuginfod/src/debuginfod_test.cpp New debuggee that steps into stdlib code to trigger debuginfod lookups.
src/MIDebugPackage/OpenFolderSchema.json Adds debuginfod to the JSON launch schema with minimum: 0 for timeout.
src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs Makes set debuginfod enabled on conditional on EnableDebuginfod.
src/MICore/Transports/LocalTransport.cs Applies debuginfod env vars (timeout/disable) when launching local GDB.
src/MICore/LaunchOptions.xsd.types.designer.cs Adds XML attributes for EnableDebuginfod and DebuginfodTimeout to generated option types.
src/MICore/LaunchOptions.xsd Adds XSD attributes + minInclusive=0 validation for DebuginfodTimeout.
src/MICore/LaunchOptions.cs Adds runtime option properties and initializes them from JSON/XML launch options.
src/MICore/JsonLaunchOptions.cs Adds debuginfod JSON model (DebuginfodSettings) to parsed launch options.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Files not reviewed (1)
  • src/MICore/LaunchOptions.xsd.types.designer.cs: Language not supported
  • Files reviewed: 10/11 changed files
  • Comments generated: 2

Comment thread src/MICore/Transports/LocalTransport.cs Outdated
Comment thread src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs
},
"debuginfod": {
"type": "object",
"description": "Controls GDB's debuginfod behavior for automatic downloading of debug symbols.",
Copy link
Copy Markdown
Member

@gregg-miskelly gregg-miskelly May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description

I think you are going to need to edit loc/lci/OpenFolderSchema.json.lci for these changes. Example: https://github.com/microsoft/MIEngine/pull/1517/changes

WardenGnaw and others added 2 commits May 19, 2026 13:03
## Why is this change being made?

Fixes microsoft/vscode-cpptools#14458

MIEngine commit f169b02 added `set debuginfod enabled on` unconditionally in
GetInitializeCommands(). On systems where DEBUGINFOD_URLS points to an
unreachable server (e.g. debuginfod.ubuntu.com which is currently down),
subsequent GDB commands block for 90+ seconds waiting for the network request
to time out, causing GDB to appear hung on launch.

## Summarize what changed

- Added a `debuginfod` launch option (JSON: `{ enabled: bool, timeout: int }`
  XML: `EnableDebuginfod`/`DebuginfodTimeout` attributes) defaulting to
  enabled with a 30-second timeout.
- When enabled (timeout > 0): sets DEBUGINFOD_TIMEOUT and DEBUGINFOD_MAXTIME
  environment variables on the GDB process to cap network requests.
- When enabled (timeout = 0): no timeout override is applied; GDB/libdebuginfod
  defaults are used.
- When disabled: clears DEBUGINFOD_URLS on the GDB process so debuginfod
  connections are never attempted, even if the system has the env var set.
- `set debuginfod enabled on` is now conditional on the EnableDebuginfod setting.
- Added XSD schema validation (minInclusive=0) and JSON schema (minimum: 0).
- Negative timeout values are clamped to the default (30) at runtime.

## How was the change tested?

- [x] Changes reviewed by Copilot CLI (using /review)
- [x] All 36 MICoreUnitTests pass
- [x] Integration tests (DebuginfodTests) pass in WSL with GDB 12.1:
      - DebuginfodDisabledDoesNotHang: steps into std::regex with unreachable
        server, verifies launch completes in < 10s
      - DebuginfodTimeoutPreventsHang: steps into std::regex with 5s timeout,
        verifies launch completes in < 30s
- [x] All existing CppTests pass (Sample, Execution, Breakpoint, Environment)
- [x] Verified via TCP listener that debuginfod URLs are actually queried
      during step-into-library operations

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@gregg-miskelly gregg-miskelly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

@WardenGnaw WardenGnaw force-pushed the dev/waan/fixDebugInfod branch from c048f2e to 99c3239 Compare May 19, 2026 20:03
PipeLaunchOptions pipeOptions = new PipeLaunchOptions(
pipePath: pipeProgram,
pipeArguments: EnsurePipeArguments(pipeArgs, debuggerPath, gdbPathDefault, quoteArgs),
pipeArguments: EnsurePipeArguments(pipeArgs, debuggerPath, gdbPathDefault, quoteArgs, debuginfodPrefix),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debuginfodPrefix

I don't think we have ever assumed before that the pipe must provide a UNIX shell.

My suggestion: change the documentation to say that the timeout will only work with local transport, and point at the GDB documentation for pipe

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

Successfully merging this pull request may close these issues.

GDB hangs on startup trying to connect to debuginfod.ubuntu.com, can't seem to be disabled

4 participants