microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.53k stars 1.56k forks source link

motd breaks pickRemoteNativeProcess #7376

Open Spongman opened 3 years ago

Spongman commented 3 years ago

Issue Type: Bug

I'm running vscode on windows connected to a linux wsl2 VM attempting to attach-debug another remote linux machine.

launch.json:

        {
            "name": "(gdb) Pipe Attach",
            "type": "cppdbg",
            "request": "attach",
            "program": "/my/to/app",
            "processId": "${command:pickRemoteProcess}",
            "pipeTransport": {
                "debuggerPath": "/opt/rh/devtoolset-9/root/usr/bin/gdb",
                "pipeProgram": "/usr/bin/ssh",
                "pipeArgs": [
                    "user@remote-host"
                ]
            },
            "MIMode": "gdb",
            "miDebuggerPath": "/opt/rh/devtoolset-9/root/usr/bin/gdb"
        },

when i start debugging the remote-attach window shows:

Linux
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 
    1 systemd                                           /usr/lib/systemd/systemd --switched-root --system --deserialize 21
...
23663 kworker/u30:1                                     [kworker/u30:1]

*******
** blah blah motd blah 
*******

and the Remote Extension Host log shows:

[2021-04-15 16:20:07.334] [exthost] [error] Error:  
*******
** blah blah motd blah 
*******

    at /home/piersh/.vscode-server/extensions/ms-vscode.cpptools-1.2.2/dist/main.js:769:24
    at ChildProcess.exithandler (child_process.js:294:7)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) extension.pickRemoteNativeProcess

turning off the motd is not an option.

Extension version: 1.3.0 VS Code version: Code 1.55.0 (c185983a683d14c396952dd432459097bc7f757f, 2021-03-30T16:01:55.261Z) OS version: Windows_NT x64 10.0.19042 Remote OS version: Linux x64 5.4.72-microsoft-standard-WSL2 Remote OS version: Linux x64 4.4.0-19041-Microsoft Remote OS version: Linux x64 3.10.0-957.1.3.el7.x86_64

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz (6 x 2904)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: enabled
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|47.66GB (11.68GB free)| |Process Argv|--crash-reporter-id 70645636-42ae-4864-b371-1810b42a2956| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|WSL: CentOS7| |OS|Linux x64 5.4.72-microsoft-standard-WSL2| |CPUs|Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz (6 x 2904)| |Memory (System)|37.35GB (17.02GB free)| |VM|0%| |Item|Value| |---|---| |Remote|WSL: Ubuntu| |OS|Linux x64 4.4.0-19041-Microsoft| |CPUs|Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz (6 x 2901)| |Memory (System)|47.66GB (11.67GB free)| |VM|0%| |Item|Value| |---|---| |Remote|SSH: dev9.corp.aetheros.com| |OS|Linux x64 3.10.0-957.1.3.el7.x86_64| |CPUs|Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz (2 x 2299)| |Memory (System)|7.64GB (2.88GB free)| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vsreu685:30147344 python383:30185418 pythonvspyt700cf:30270857 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492cf:30256860 vstry914:30276682 pythonvsdeb440:30248342 pythonvsded773:30248341 pythonvspyt875:30259475 pythontb:30283811 wslfolderdoccf:30282075 vspre833cf:30267465 pythonptprofiler:30281270 vsdfh931cf:30280410 vshan820cf:30276953 pythondataviewer:30285071 vscus158cf:30286554 ```
WardenGnaw commented 3 years ago

This is due to the AttachToProcess dialog expecting the first line to be the response to uname and the following lines to be the ps command.

See https://github.com/microsoft/vscode-cpptools/blob/88768b9c285036a57490319ccfe0eaae8cb1a6d3/Extension/src/Debugger/attachToProcess.ts#L147

Spongman commented 3 years ago

are you sure? if i test on a machine without motd, the output shown in the remote-attach window is essentially the same (but without the motd appended), and the attach works fine.

i think the issue is that the motd is output on stderr, and the debugger is naively interpreting that as an error: /home/piersh/.vscode-server/extensions/ms-vscode.cpptools-1.2.2/dist/main.js:769:24:

            if (stderr && stderr.length > 0) {
                reject(new Error(stderr));
                return;
            }