microsoft / microsoft/vscode-cpptools

debug server startup fails due to stdout buffering

Open
#9,388 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug debugger
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Issue Type: Bug

This is probably actually a problem in MIEngine.

I'm using the Arduino extension on macOS, and debugging with avarice and avr-gdb, but this problem also occurs if I configure a plain cppdbg instance in launch.json instead of using the Arduino extension's debugger.

If specifying a debug server to start, it apparently gets launched with pipes, not a pseudo-terminal. If it doesn't flush its stdout, then VS Code will probably never see its startup message, and therefore time out on starting it.

This category of bug seems to have been reported multiple times, usually without resolution, and usually by people working with gdb debug servers.

On macOS, there is a workaround of using /usr/bin/env as debugServerPath, and specifying STDBUF1=L with the rest of the debug server path and arguments.

Arguably, authors of debug servers should line-buffer or explicitly flush their status messages sent to stdout, but this is a subtle interaction that is unlikely to be reported or well-troubleshooted.

Extension version: 1.9.8
VS Code version: Code 1.67.2 (Universal) (c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5, 2022-05-17T18:20:57.384Z)
OS version: Darwin x64 19.6.0
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz (8 x 3100)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 2, 2, 2
Memory (System) 16.00GB (0.08GB free)
Process Argv --crash-reporter-id 8c334355-bde7-413a-8609-0fd7d4a582f2
Screen Reader no
VM 22%

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with a cppdbg launch configuration using debugServerPath and a server that does not flush stdout; compare it with the /usr/bin/env and STDBUF1=L workaround. Trace the debug-server startup timeout and define done as reliably detecting the server's startup message when stdout is connected through pipes.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, cpp, macos
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.