Exception on inserting breakpoint into running program (GDB on Windows) · Issue #14838 · microsoft/vscode-cpptools · GitHub
Skip to content

Exception on inserting breakpoint into running program (GDB on Windows) #14838

Open

Description

Environment

  • OS and version: Windows 26H2 26300.9457
  • VS Code: 1.142.0
  • C/C++ extension: 1.34.4
  • GDB / LLDB version: 18.1, MSYS2 ucrt64 package

Bug Summary and Steps to Reproduce

Bug Summary:
On Windows, using gdb as a debugger for the program, inserting breakpoint when application is running causes exception:
Exception has occurred.
Signal 0

Steps to reproduce:

  1. Compile simple program with infinite loop, with debugging option -g, for example :
#include <stdint.h>

int main()
{
	uint32_t a = 0;
	uint32_t b = 1;
	uint32_t c;

	while (true)
	{
		c = a + b;
		a = b;
		b = c;
	}

	return 0;
}
  1. Launch program using this configuration
    launch.json :
{
   "version": "0.2.0",
   "configurations": [
      {
         "name": "Launch app",
         "type": "cppdbg",
         "request": "launch",
         "program": "${workspaceFolder}\\app.exe",
         "args": [],
         "stopAtEntry": false,
         "cwd": "${workspaceFolder}",
         "environment": [],
         "externalConsole": true,
         "MIMode": "gdb",
         "miDebuggerPath": "E:\\_Installed\\Programs\\MSYS2\\ucrt64\\bin\\gdb.exe",
         "setupCommands": [
            {
               "description": "Enable code formating for gdb",
               "text": "-enable-pretty-printing",
               "ignoreFailures": true
            },
				{
					"text": "set charset UTF-8"
			   },
            {
               "description": "Update breakpoints immediately",
               "text": "set breakpoint always-inserted on",
               "ignoreFailures": true
            }
         ],
         "logging":
         {
            "engineLogging": true,
            "trace": true,
            "traceResponse": true
         }
      },
   ]
}

  1. Insert breakpoint, for example on c = a + b.
  2. Exception pops up:
Exception has occurred.
Signal 0

Debugger Configurations

launch.json:
{
   "version": "0.2.0",
   "configurations": [
      {
         "name": "Launch app",
         "type": "cppdbg",
         "request": "launch",
         "program": "${workspaceFolder}\\app.exe",
         "args": [],
         "stopAtEntry": false,
         "cwd": "${workspaceFolder}",
         "environment": [],
         "externalConsole": true,
         "MIMode": "gdb",
         "miDebuggerPath": "E:\\_Installed\\Programs\\MSYS2\\ucrt64\\bin\\gdb.exe",
         "setupCommands": [
            {
               "description": "Enable code formating for gdb",
               "text": "-enable-pretty-printing",
               "ignoreFailures": true
            },
				{
					"text": "set charset UTF-8"
			   },
            {
               "description": "Update breakpoints immediately",
               "text": "set breakpoint always-inserted on",
               "ignoreFailures": true
            }
         ],
         "logging":
         {
            "engineLogging": true,
            "trace": true,
            "traceResponse": true
         }
      },
   ]
}

Debugger Logs

Output from debug console:


<--   C (setBreakpoints-11): {"command":"setBreakpoints","arguments":{"source":{"name":"main.cpp","path":"e:\\_P\\VScode\\Crater\\src\\main.cpp"},"lines":[11],"breakpoints":[{"line":11}],"sourceModified":false},"type":"request","seq":11}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4776) <-1026-exec-interrupt\r\n"},"seq":641}
1: (4776) <-1026-exec-interrupt
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4779) ->1026^done\r\n"},"seq":643}
1: (4779) ->1026^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4779) ->(gdb)\r\n"},"seq":645}
1: (4779) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4779) 1026: elapsed time 2\r\n"},"seq":647}
1: (4779) 1026: elapsed time 2
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4779) ->~\"\\nThread \"\r\n"},"seq":649}
1: (4779) ->~"\nThread "
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4779) ->~\"1 stopped.\\n\"\r\n"},"seq":651}
1: (4779) ->~"1 stopped.\n"
--> E (output): {"type":"event","event":"output","body":{"category":"stdout","output":"\nThread "},"seq":653}

Thread 
--> E (output): {"type":"event","event":"output","body":{"category":"stdout","output":"1 stopped.\n"},"seq":655}
1 stopped.
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4779) ->~\"0x00007ff700051024 in main () at E:/_P/VScode/Crater/src/main.cpp:11\\n\"\r\n"},"seq":657}
1: (4779) ->~"0x00007ff700051024 in main () at E:/_P/VScode/Crater/src/main.cpp:11\n"
--> E (output): {"type":"event","event":"output","body":{"category":"stdout","output":"0x00007ff700051024 in main () at E:/_P/VScode/Crater/src/main.cpp:11\n"},"seq":659}
0x00007ff700051024 in main () at E:/_P/VScode/Crater/src/main.cpp:11
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4779) ->~\"11\\t\\t\\tc = a + b;\\n\"\r\n"},"seq":661}
1: (4779) ->~"11\t\t\tc = a + b;\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4779) ->*stopped,reason=\"signal-received\",signal-name=\"0\",signal-meaning=\"Signal 0\",frame={addr=\"0x00007ff700051024\",func=\"main\",args=[],file=\"E:/_P/VScode/Crater/src/main.cpp\",fullname=\"E:/_P/VScode/Crater/src/main.cpp\",line=\"11\",arch=\"i386:x86-64\"},thread-id=\"1\",stopped-threads=\"all\"\r\n"},"seq":663}
1: (4779) ->*stopped,reason="signal-received",signal-name="0",signal-meaning="Signal 0",frame={addr="0x00007ff700051024",func="main",args=[],file="E:/_P/VScode/Crater/src/main.cpp",fullname="E:/_P/VScode/Crater/src/main.cpp",line="11",arch="i386:x86-64"},thread-id="1",stopped-threads="all"
--> E (output): {"type":"event","event":"output","body":{"category":"stdout","output":"11\t\t\tc = a + b;\n"},"seq":664}
11			c = a + b;
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4779) ->&\"\\n\"\r\n"},"seq":667}
1: (4779) ->&"\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4779) <-1027-break-insert -f main.cpp:11\r\n"},"seq":669}
1: (4779) <-1027-break-insert -f main.cpp:11
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4784) ->^done\r\n"},"seq":671}
1: (4784) ->^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4784) ->(gdb)\r\n"},"seq":673}
1: (4784) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4795) ->1027^done,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"0x00007ff70005101c\",func=\"main()\",file=\"E:/_P/VScode/Crater/src/main.cpp\",fullname=\"E:/_P/VScode/Crater/src/main.cpp\",line=\"11\",thread-groups=[\"i1\"],times=\"0\",original-location=\"main.cpp:11\"}\r\n"},"seq":675}
1: (4795) ->1027^done,bkpt={number="3",type="breakpoint",disp="keep",enabled="y",addr="0x00007ff70005101c",func="main()",file="E:/_P/VScode/Crater/src/main.cpp",fullname="E:/_P/VScode/Crater/src/main.cpp",line="11",thread-groups=["i1"],times="0",original-location="main.cpp:11"}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4795) ->(gdb)\r\n"},"seq":677}
1: (4795) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4795) 1027: elapsed time 15\r\n"},"seq":679}
1: (4795) 1027: elapsed time 15
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4795) ->&\"\\n\"\r\n"},"seq":681}
1: (4795) ->&"\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4795) ->^done\r\n"},"seq":683}
1: (4795) ->^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4795) ->(gdb)\r\n"},"seq":685}
1: (4795) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4797) <-1028-symbol-list-lines E:/_P/VScode/Crater/src/main.cpp\r\n"},"seq":687}
1: (4797) <-1028-symbol-list-lines E:/_P/VScode/Crater/src/main.cpp
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4810) ->1028^done,lines=[{pc=\"0x00007ff700051000\",line=\"4\"},{pc=\"0x00007ff70005100c\",line=\"5\"},{pc=\"0x00007ff700051014\",line=\"6\"},{pc=\"0x00007ff70005101c\",line=\"11\"},{pc=\"0x00007ff700051020\",line=\"11\"},{pc=\"0x00007ff700051024\",line=\"11\"},{pc=\"0x00007ff700051027\",line=\"12\"},{pc=\"0x00007ff70005102b\",line=\"12\"},{pc=\"0x00007ff70005102f\",line=\"13\"},{pc=\"0x00007ff700051032\",line=\"13\"},{pc=\"0x00007ff700051036\",line=\"9\"},{pc=\"0x00007ff700051038\",line=\"0\"}]\r\n"},"seq":689}
1: (4810) ->1028^done,lines=[{pc="0x00007ff700051000",line="4"},{pc="0x00007ff70005100c",line="5"},{pc="0x00007ff700051014",line="6"},{pc="0x00007ff70005101c",line="11"},{pc="0x00007ff700051020",line="11"},{pc="0x00007ff700051024",line="11"},{pc="0x00007ff700051027",line="12"},{pc="0x00007ff70005102b",line="12"},{pc="0x00007ff70005102f",line="13"},{pc="0x00007ff700051032",line="13"},{pc="0x00007ff700051036",line="9"},{pc="0x00007ff700051038",line="0"}]
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4810) ->(gdb)\r\n"},"seq":691}
1: (4810) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4810) ->&\"\\n\"\r\n"},"seq":693}
1: (4810) ->&"\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4810) ->^done\r\n"},"seq":695}
1: (4810) ->^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4810) ->(gdb)\r\n"},"seq":697}
1: (4810) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4810) 1028: elapsed time 13\r\n"},"seq":699}
1: (4810) 1028: elapsed time 13
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4814) Send Event AD7BreakpointBoundEvent\r\n"},"seq":701}
1: (4814) Send Event AD7BreakpointBoundEvent
--> R (setBreakpoints-11): {"type":"response","request_seq":11,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"id":2,"verified":true,"line":11,"BoundBreakpoints":[]}]},"seq":703}
--> E (breakpoint): {"type":"event","event":"breakpoint","body":{"reason":"changed","breakpoint":{"id":2,"verified":true,"line":11,"BoundBreakpoints":[]}},"seq":705}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4816) <-1029-stack-list-frames --thread 1 0 1000\r\n"},"seq":707}
1: (4816) <-1029-stack-list-frames --thread 1 0 1000
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4825) ->1029^done,stack=[frame={level=\"0\",addr=\"0x00007ff700051024\",func=\"main\",file=\"E:/_P/VScode/Crater/src/main.cpp\",fullname=\"E:/_P/VScode/Crater/src/main.cpp\",line=\"11\",arch=\"i386:x86-64\"}]\r\n"},"seq":709}
1: (4825) ->1029^done,stack=[frame={level="0",addr="0x00007ff700051024",func="main",file="E:/_P/VScode/Crater/src/main.cpp",fullname="E:/_P/VScode/Crater/src/main.cpp",line="11",arch="i386:x86-64"}]
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4826) ->(gdb)\r\n"},"seq":711}
1: (4826) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4826) 1029: elapsed time 9\r\n"},"seq":713}
1: (4826) 1029: elapsed time 9
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4826) ->&\"\\n\"\r\n"},"seq":715}
1: (4826) ->&"\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4826) ->^done\r\n"},"seq":717}
1: (4826) ->^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4826) ->(gdb)\r\n"},"seq":719}
1: (4826) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4828) Send Event AD7ExceptionEvent\r\n"},"seq":721}
1: (4828) Send Event AD7ExceptionEvent
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"Execute debugger commands using \"-exec <command>\", for example \"-exec info registers\" will list registers in use (when GDB is the debugger)\r\n"},"seq":723}
Execute debugger commands using "-exec <command>", for example "-exec info registers" will list registers in use (when GDB is the debugger)
--> E (stopped): {"type":"event","event":"stopped","body":{"reason":"exception","threadId":1,"text":"Signal 0","allThreadsStopped":true,"source":{"name":"main.cpp","path":"e:\\_P\\VScode\\Crater\\src\\main.cpp","sources":[],"checksums":[]},"line":11,"column":1},"seq":725}
<--   C (threads-12): {"command":"threads","type":"request","seq":12}
--> R (threads-12): {"type":"response","request_seq":12,"success":true,"command":"threads","body":{"threads":[{"id":1,"name":" [1]"},{"id":2,"name":" [2]"},{"id":3,"name":" [3]"},{"id":4,"name":" [4]"}]},"seq":728}
<--   C (stackTrace-13): {"command":"stackTrace","arguments":{"threadId":1,"startFrame":0,"levels":20},"type":"request","seq":13}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4851) <-1030-list-features\r\n"},"seq":731}
1: (4851) <-1030-list-features
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4856) ->1030^done,features=[\"frozen-varobjs\",\"pending-breakpoints\",\"thread-info\",\"data-read-memory-bytes\",\"breakpoint-notifications\",\"ada-task-info\",\"language-option\",\"info-gdb-mi-command\",\"undefined-command-error-code\",\"exec-run-start-option\",\"data-disassemble-a-option\",\"simple-values-ref-types\",\"python\"]\r\n"},"seq":733}
1: (4856) ->1030^done,features=["frozen-varobjs","pending-breakpoints","thread-info","data-read-memory-bytes","breakpoint-notifications","ada-task-info","language-option","info-gdb-mi-command","undefined-command-error-code","exec-run-start-option","data-disassemble-a-option","simple-values-ref-types","python"]
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4856) ->(gdb)\r\n"},"seq":735}
1: (4856) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4856) ->&\"\\n\"\r\n"},"seq":737}
1: (4856) ->&"\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4857) ->^done\r\n"},"seq":739}
1: (4857) ->^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4857) ->(gdb)\r\n"},"seq":741}
1: (4857) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4857) 1030: elapsed time 5\r\n"},"seq":743}
1: (4857) 1030: elapsed time 5
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4858) <-1031-stack-list-arguments --thread 1 2 0 0\r\n"},"seq":745}
1: (4858) <-1031-stack-list-arguments --thread 1 2 0 0
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4872) ->1031^done,stack-args=[frame={level=\"0\",args=[]}]\r\n"},"seq":747}
1: (4872) ->1031^done,stack-args=[frame={level="0",args=[]}]
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4872) ->(gdb)\r\n"},"seq":749}
1: (4872) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4872) ->&\"\\n\"\r\n"},"seq":751}
1: (4872) ->&"\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4872) ->^done\r\n"},"seq":753}
1: (4872) ->^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4872) ->(gdb)\r\n"},"seq":755}
1: (4872) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (4872) 1031: elapsed time 14\r\n"},"seq":757}
1: (4872) 1031: elapsed time 14
--> R (stackTrace-13): {"type":"response","request_seq":13,"success":true,"command":"stackTrace","body":{"stackFrames":[{"id":1000,"name":"main()","source":{"name":"main.cpp","path":"e:\\_P\\VScode\\Crater\\src\\main.cpp","sources":[],"checksums":[]},"line":11,"column":1,"instructionPointerReference":"0x00007ff700051024"}],"totalFrames":1},"seq":759}
<--   C (evaluate-14): {"command":"evaluate","arguments":{"expression":"return","frameId":1000,"context":"hover","line":16,"column":2,"source":{"name":"main.cpp","path":"e:\\_P\\VScode\\Crater\\src\\main.cpp","sources":[],"checksums":[]}},"type":"request","seq":14}
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5836) <-1032-var-create --thread 1 --frame 0  - * \"return\"\r\n"},"seq":762}
1: (5836) <-1032-var-create --thread 1 --frame 0  - * "return"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5849) ->1032^error,msg=\"-var-create: unable to create variable object\"\r\n"},"seq":764}
1: (5849) ->1032^error,msg="-var-create: unable to create variable object"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5849) ->(gdb)\r\n"},"seq":766}
1: (5849) ->(gdb)
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5849) 1032: elapsed time 12\r\n"},"seq":768}
1: (5849) 1032: elapsed time 12
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5849) ->&\"\\n\"\r\n"},"seq":770}
1: (5849) ->&"\n"
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5849) ->^done\r\n"},"seq":772}
1: (5849) ->^done
--> E (output): {"type":"event","event":"output","body":{"category":"console","output":"1: (5849) ->(gdb)\r\n"},"seq":774}
1: (5849) ->(gdb)
--> R (evaluate-14): {"type":"response","request_seq":14,"success":false,"command":"evaluate","message":"Evaluation error","body":{},"seq":776}

Other Extensions

No response

Additional Information

Exception shows the moment breakpoint is placed.
Image
This is small program to reproduce it.
Originally the issue was in somewhat bigger program with WinApi window created and GetMessageA() function in infinite loop. There the exception was shown to be at GetMessageA().

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions