microsoft / microsoft/vscode-cpptools

Debugger launched executable seems not able to access wsl command

Open
#13,641 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Environment
  • OS and version: Windows 11
  • VS Code: 1.100.2
  • C/C++ extension: ms-vscode.cpptools@1.25.3
  • OS and version of remote machine (if applicable):
  • GDB / LLDB version: GNU gdb (GDB) 16.2
Bug Summary and Steps to Reproduce

Bug Summary:

The program launched by debugger seems not able to use wsl.
Same as #13110, manually executing the program in the same/other integrated terminal works, external works.

Access is denied. 
Error code: Wsl/Service/E_ACCESSDENIED

Image

Image

Steps to reproduce:

  1. Open a folder
  2. Create code:
  3. F5 choose detected task "C/C++: g++.exe build active file", auto-generated a tasks.json under ./.vscode
  4. Open redirected outputs
    Code:
#include <bits/stdc++.h>
using namespace std;
void closePipe(FILE *pipe)
{
    if (pipe)
    {
        pclose(pipe);
    }
}
int main(int argc, char *args[])
{
    auto pipe = popen("wsl --shell-type none -- ls . 1>pipe1 2>&1", "r");
    closePipe(pipe);
    auto pipe2 = popen("wsl --shell-type none -- ls . 1>pipe2 2>&1", "r");
    closePipe(pipe2);
    auto pipe3 = popen("dir . 1>pipe3  2>&1", "r");
    closePipe(pipe3);
    return 0;
}
Debugger Configurations
tasks.json

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe build active file",
            "command": "D:\\Build_Tool_Lib\\x86_64-15.1.0-release-win32-seh-msvcrt-rt_v12-rev0\\mingw64\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}


launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/${fileBasenameNoExtension}",
            "externalConsole": false,
            "cwd": "${fileDirname}",
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\Build_Tool_Lib\\x86_64-15.1.0-release-win32-seh-msvcrt-rt_v12-rev0\\mingw64\\bin\\gdb.exe",
            "logging": {
                "engineLogging": true,
                "trace": true,
                "traceResponse": true
            }
        }
    ]
}
Debugger Logs

Console logs

C/C++ outputs:
Launch configuration:
{
  "name": "(gdb) Launch",
  "type": "cppdbg",
  "request": "launch",
  "program": "C:\\Users\\rabbit\\Desktop\\CPPTools/Hello",
  "externalConsole": false,
  "cwd": "C:\\Users\\rabbit\\Desktop\\CPPTools",
  "MIMode": "gdb",
  "miDebuggerPath": "D:\\Build_Tool_Lib\\x86_64-15.1.0-release-win32-seh-msvcrt-rt_v12-rev0\\mingw64\\bin\\gdb.exe",
  "logging": {
    "engineLogging": true,
    "trace": true,
    "traceResponse": true
  },
  "__configurationTarget": 6
}
Other Extensions

No response

Additional Information

No response

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 using the generated .vscode/tasks.json and launch.json, then read the linked debugger console logs and compare the behavior with issue #13110. Done means the debugger-launched executable can run the reported wsl command without E_ACCESSDENIED, while the existing terminal behavior remains unaffected.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vscode
Domain
devtools, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.