Skip to content

VSCode executes files opened from processes debugged by cppvsdbg in node.js #13644

Closed
@sadan4

Description

@sadan4

Environment

  • OS and version: Windows 22H2 (OS Build 19045.2006)
  • VS Code: 1.100.2
  • C/C++ extension: 1.25.3
  • OS and version of remote machine (if applicable): N/A
  • GDB / LLDB version: N/A

Bug Summary and Steps to Reproduce

Bug Summary:
If a process debugged by cppvsdbg attempts to launch a file in its default application, and said application is vscode, vscode will execute the file in Node.js

Steps to reproduce:

  1. Using this repo https://github.com/sadan4/vscppdbg-repro
  2. Make sure VS Code is your default application for opening text files
  3. Change the path in main.c for your environment
  4. Compile main.c. I've reproduced this with gcc main.c and clang main.c -lShell32.
  5. Start the debugging session
  6. Observe in the external console that the file is executed as JavaScript and not opened in VS Code

Video (taken in a VM):

2025-05-27.19-55-33.mov

Notes:

  • I cannot reproduce this with gdb at all
  • When I attempted to reproduce this in a VM, I was not able to get the output from Node.js 100% of the time, however it never opened the file properly
  • I have reproduced this bug with many types of files (c, txt, js, css, ...)
  • The contents of the opened file do not matter; it will throw a syntax error if it's not valid JavaScript
  • If the file has no default association and Windows prompts for one to be selected, it will work properly
  • any form of opening the file results in this error eg: calling out powershell to open the file

Debugger Configurations

https://github.com/sadan4/vscppdbg-repro/blob/master/.vscode/launch.json

Debugger Logs

Hello World
for some reason, vscode runs this as a js file in node only when lanuched from a process being debugged by cppvsdbg
some info:
ARGV:  [
  'C:\\Users\\user\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe',
  'C:\\repro\\file.txt'
]
require.main:  {
  id: '.',
  path: 'C:\\repro',
  exports: {},
  filename: 'C:\\repro\\file.txt',
  loaded: false,
  children: [],
  paths: [ 'C:\\repro\\node_modules' ],
  [Symbol(kIsMainSymbol)]: true,
  [Symbol(kIsCachedByESMLoader)]: false,
  [Symbol(kIsExecuting)]: true
}
 
C:\repro\file.txt:3
throw new Error();
^
 
Error
    at Object.<anonymous> (C:\repro\file.txt:3:7)
    at Module._compile (node:internal/modules/cjs/loader:1544:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1629:10)
    at Module.load (node:internal/modules/cjs/loader:1282:32)
    at Module._load (node:internal/modules/cjs/loader:1103:12)
    at c._load (node:electron/js2c/node_init:2:16955)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:179:12)
    at node:internal/main/run_main_module:28:49
 
Node.js v20.19.0

Other Extensions

I only have C/C++ and C/C++ Themes installed

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions