franneck94 / Vscode-C-Cpp-Runner

🚀 Compile, run and debug single or multiple C/C++ files with ease. 🚀
MIT License
53 stars 14 forks source link

The "args" property in launch.json assigns null to file pointer #164

Closed katiyaya closed 1 week ago

katiyaya commented 2 weeks ago

Type: Bug

  1. Arguments are passed to the desired target, the program executes, passes the needed number of arguments (argc) check, but assigns NULL to file pointer when trying to open the file passed as an argument. The program is executes normally without any issues on bash with the provided command line argument.
  2. Application executes normally in bash via ./Application testcases/singlefailure.conf command

Platform and versions: Operating System: Ubuntu VSCode Version: 1.94.0 Compiler/Toolchain: GCC 11.4.0 C/C++ Runner v 9.4.9

Launch.json { "version": "0.2.0", "configurations": [ { "name": "C/C++ Runner: Debug Session", "type": "cppdbg", "request": "launch", "args": [ "testcases/singlefailure.conf" ], "stopAtEntry": false, "externalConsole": false, "cwd": "/home/katiyabrk/my-gossip-protocol/testcases", "program": "/home/katiyabrk/my-gossip-protocol/Application", "MIMode": "gdb", "miDebuggerPath": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] } P.S. I had problems with passing the arguments when the argc wasn't correct, as i.ve searched it was an issue https://github.com/microsoft/vscode-cmake-tools/issues/1594, but i managed it by installing the C/C++ runner which seems to accept the arguments but the file pointer is assigned NULL. Could this be related to the issue described in the link above?

Extension version: 9.4.9 VS Code version: Code 1.94.0 (d78a74bcdfad14d5d3b1b782f87255d802b57511, 2024-10-02T13:08:12.626Z) OS version: Windows_NT x64 10.0.19045 Modes: Remote OS version: Linux x64 5.15.153.1-microsoft-standard-WSL2

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz (4 x 2891)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off| |Load (avg)|undefined| |Memory (System)|7.91GB (1.04GB free)| |Process Argv|--crash-reporter-id 3d34cbf7-87ca-46ed-bc7b-891051e30360| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|WSL: Ubuntu| |OS|Linux x64 5.15.153.1-microsoft-standard-WSL2| |CPUs|Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz (4 x 0)| |Memory (System)|3.78GB (2.40GB free)| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492:30256859 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 2i9eh265:30646982 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonnoceb:30805159 asynctok:30898717 pythonmypyd1:30879173 h48ei257:31000450 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 g316j359:31013175 a69g1124:31058053 dvdeprecation:31068756 dwnewjupytercf:31046870 impr_priority:31102340 nativerepl2:31139839 refactort:31108082 pythonrstrctxt:31112756 flighttreat:31134774 wkspc-onlycs-t:31132770 wkspc-ranged-t:31151552 cf971741:31144450 autoexpandse:31146404 notype1cf:31151524 cc771715:31146322 ```
franneck94 commented 2 weeks ago

Can you print out the argv values to the console? I just want to see what's inside the argv

katiyaya commented 2 weeks ago

Screenshot (15) This causes segmentation fault due to lack of file later in the code Screenshot (19)

franneck94 commented 2 weeks ago

Please post a screenshot with the actual values of argv, you posted the address of the first value. In the debugger view you can expand it, to see all values

katiyaya commented 2 weeks ago

Screenshot (20)

franneck94 commented 2 weeks ago

Sorry I meant the full content of argv, that's just the first character.

franneck94 commented 2 weeks ago

You should get it by

argv[1],20

In the debug console

franneck94 commented 2 weeks ago

Or you could just convert it to a c++ string, that's easier to debug

katiyaya commented 1 week ago

Screenshot (22) Hope that's correct

franneck94 commented 1 week ago

Yes thanks. So it seems that the path to the file is correct, isnt it? So its rather an issue with you code. For example you are using relative paths that do not match instead of absolute paths.

katiyaya commented 1 week ago

Thank you, using the absolute path helped fix the problem.