vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Debugger deadlocks when using breakpoints within a function accessed by "-exec call"

Open Marsy-git opened this issue 3 years ago • 1 comments

Environment

  • OS and version: Debian GNU/Linux 11 (bullseye)
  • VS Code: 1.68.1 30d9c6cd9483b2cc586687151bcbcd635f373630 x64
  • C/C++ extension: v1.10.8
  • OS and version of remote machine (if applicable): [not applicable]
  • GDB / LLDB version: GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git

Also happens on Arch:

  • OS and version: Arch Linux
  • VS Code: 1.69.1
  • C/C++ extension: v1.10.8
  • OS and version of remote machine (if applicable): [not applicable]
  • GDB / LLDB version: GNU gdb (GDB) 12.1

Bug Summary and Steps to Reproduce

Bug Summary: When setting a breakpoint in a function that is then called manually by gdb using "-exec call [function]", the function is executed normally and the breakpoint is hit, but upon returning from the function, by either pressing "continue" or completely stepping through it, the debugging UI locks up ( the debugee is displayed as "running" forever and cannot be paused; the debugee can still be stopped or restarted). The issue does not occur if gdb is used independently(launching it outside vscode[1]) or gdb is only used from within the integrated debug console[2].

Steps to reproduce:

  1. In this environment: Vscode opened with a simple program[3] that has a callable function as well as another function that will be executed while running the program. A (debug) compiled (g++ -g main.cpp -o testbin) version of this program within the project directory.
  2. With this config: [see "Debugger Configurations"], no custom gdb config
  3. Do: Use the vscode UI to set a breakpoint on line 10 and line 5. Start a debugging session using launch.json[see Debugger Configurations]. Once the breakpoint on line 10 has been reached, input "-exec call printNumber(2)" into the "debug console". Upon hitting the breakpoint on line 5, hit "continue".
  4. See error: No error message, only the issue described above.

Debugger Configurations

{
    // launch.json
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/testbin",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }

    ]
}
// no tasks.json was used

Debugger Logs

executing "-exec call printNumber(2)"
--> R (scopes-23): {"type":"response","request_seq":23,"success":true,"command":"scopes","body":{"scopes":[{"presentationHint":"locals","name":"Locals","variablesReference":1004,"expensive":false},{"presentationHint":"registers","name":"Registers","variablesReference":1005,"expensive":true}]},"seq":533}
<--   C (variables-24): {"command":"variables","arguments":{"variablesReference":1004},"type":"request","seq":24}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (40807) <-1035-stack-list-variables 0\n"},"seq":536}
1: (40807) <-1035-stack-list-variables 0
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (40807) ->1035^done,variables=[{name=\"i\",arg=\"1\"}]\n"},"seq":538}
1: (40807) ->1035^done,variables=[{name="i",arg="1"}]
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (40808) ->(gdb)\n"},"seq":540}
1: (40808) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (40808) 1035: elapsed time 0\n"},"seq":542}
1: (40808) 1035: elapsed time 0
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (40808) <-1036-var-create - * \"i\"\n"},"seq":544}
1: (40808) <-1036-var-create - * "i"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (40808) ->1036^done,name=\"var3\",numchild=\"0\",value=\"2\",type=\"int\",thread-id=\"1\",has_more=\"0\"\n"},"seq":546}
1: (40808) ->1036^done,name="var3",numchild="0",value="2",type="int",thread-id="1",has_more="0"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (40808) ->(gdb)\n"},"seq":548}
1: (40808) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (40808) 1036: elapsed time 0\n"},"seq":550}
1: (40808) 1036: elapsed time 0
--> R (variables-24): {"type":"response","request_seq":24,"success":true,"command":"variables","body":{"variables":[{"name":"i","value":"2","type":"int","evaluateName":"i","variablesReference":0,"memoryReference":"0x0000000000000002"}]},"seq":552}

hitting continue:
<--   C (continue-25): {"command":"continue","arguments":{"threadId":34773},"type":"request","seq":25}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (173641) <--exec-continue\n"},"seq":555}
1: (173641) <--exec-continue
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (173642) ->^running\n"},"seq":558}
1: (173642) ->^running
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (173642) ->*running,thread-id=\"all\"\n"},"seq":560}
1: (173642) ->*running,thread-id="all"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (173642) ->(gdb)\n"},"seq":562}
1: (173642) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (173642) ->*stopped\n"},"seq":564}
1: (173642) ->*stopped
--> R (continue-25): {"type":"response","request_seq":25,"success":true,"command":"continue","body":{},"seq":557}
<--   C (evaluate-26): {"command":"evaluate","arguments":{"expression":"iostream","frameId":1001,"context":"hover"},"type":"request","seq":26}
--> R (evaluate-26): {"type":"response","request_seq":26,"success":false,"command":"evaluate","message":"Failed to handle EvaluateRequest","body":{"error":{"id":1105,"format":"Unable to perform this action because the process is running."}},"seq":568}

Other Extensions

All other extensions have been disabled.

Additional Information

[1]: Using gdb directly:

gdb testing
GNU gdb (Debian 10.1-1.7) 10.1.90.20210103-git
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from testing...
(gdb) b main
Breakpoint 1 at 0x40122f: file /ssd2/distroboxSteamContainer/testing/main.cpp, line 10.
(gdb) b printNumber
Breakpoint 2 at 0x4011cb: file /ssd2/distroboxSteamContainer/testing/main.cpp, line 5.
(gdb) r
Starting program: /ssd2/distroboxSteamContainer/testing/build/testing 

Breakpoint 1, main () at /ssd2/distroboxSteamContainer/testing/main.cpp:10
10	    std::cout << "something else\n";
(gdb) call printNumber(2)

Breakpoint 2, printNumber (i=2) at /ssd2/distroboxSteamContainer/testing/main.cpp:5
5	    std::cout << "The value is: " << i << "\n";
The program being debugged stopped while in a function called from GDB.
Evaluation of the expression containing the function
(printNumber(int)) will be abandoned.
When the function is done executing, GDB will silently stop.
(gdb) c
Continuing.
The value is: 2
(gdb) c
Continuing.
something else
[Inferior 1 (process 35237) exited normally]
(gdb) quit

[2]: Using the debug console: [setup similar to actual bug]

  1. In this environment: Vscode opened with a simple program[3] that has a callable function as well as another function that will be executed while running the program. A (debug) compiled (g++ -g main.cpp -o testbin) version of this program within the project directory.

  2. With this config: [see "Debugger Configurations"], no custom gdb config

  3. Do: Use the vscode UI to set a breakpoint (only) on line 10. Start a debugging session using launch.json[see Debugger Configurations]. Once the breakpoint on line 10 has been reached: input "-exec b printNumber" input "-exec call printNumber(2)" input "-exec c" press "continue" [Interestingly, while gdb claims, that the program is continuing after the "-exec c", only the function
    printNumber is executed and vscode still shows the program stuck on the breakpoint created through "-exec b printNumber"; only pressing "continue" resolves this, at which point the breakpoint on line 10 is ignored and the program runs to completion]

    If the debug stepping UI is used before the part mentioned above, the same lockup-state this issue revolves around, occurs.

[3]: The simple program:

1. #include <iostream>
2. 
3. 
4. bool printNumber(int i){
5.     std::cout << "The value is: " << i << "\n";
6.     return true;
7. }
8. 
9. int main(int, char**) {
10.     std::cout << "something else\n";
11. }

Marsy-git avatar Jul 15 '22 17:07 Marsy-git

Thank you for reporting this issue. We’ll let you know if we need more information to investigate it.

WardenGnaw avatar Jul 16 '22 00:07 WardenGnaw

This issue has been closed as lower priority. We're sorry if this issue still impacts you but unfortunately we're not able to address this. We will accept a pull request from the community if it's applicable for this issue.

github-actions[bot] avatar Jan 12 '23 11:01 github-actions[bot]