As it was suggested on the project's IRC channel, I am opening a preliminary discussion of my issue in this mailing list.
I encountered an internal GDB error while was debugging C++ code using Microsoft Windows thread pool API[1]. When several works/threads hit the same breakpoint at the same time, I got the following GDB error: > ../../../../src/gdb-8.0.1/gdb/infrun.c:5575: internal-error: int > finish_step_over(execution_control_state*): Assertion > `ecs->event_thread->control.trap_expected' failed. Detailed information and sample code come below. Compiler: mingw-w64 GCC (7.1 - 7.3); GDB (8.0.1 and 8.1); host OS is Microsoft Windows 10 x64. There is the sample code in the attachment. The code initializes thread pool object and runs three background threads/works that almost do nothing. The problem appears if one set a breakpoint (with the `break`, `dprintf`, etc.) inside the thread's callback function. When the threads hit that breakpoint at the same time, the internal error raises. The works submitted to the execution in the `for` loop, because usually the error appears on the second submitting and rarely on the first (see output log below). Command line to compile the sample: ``` g++ -x c++ -std=gnu++1z -m64 -gdwarf -g3 -D_WIN32_WINNT=_WIN32_WINNT_WIN10 -DWINVER=_WIN32_WINNT_WIN10 -DDEBUG sample.cxx ``` Below is dump of a GDB session: ``` D:\p>gdb -se a.exe GNU gdb (GDB) 8.0.1 Copyright (C) 2017 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-w64-mingw32". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://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 a.exe...done. (gdb) dprintf sample.cxx:22, "[a] In a background thread.\n" Dprintf 1 at 0x401574: file sample.cxx, line 22. (gdb) r Starting program: D:\p\a.exe [New Thread 11420.0x308c] [New Thread 11420.0x21f0] [New Thread 11420.0x2c18] [New Thread 11420.0x1a48] [New Thread 11420.0x2c80] [New Thread 11420.0x1b04] [a] In a background thread. [a] In a background thread. [New Thread 11420.0x2404] [a] In a background thread. [a] In a background thread. ../../../../src/gdb-8.0.1/gdb/infrun.c:5575: internal-error: int finish_step_over(execution_control_state*): Assertion `ecs->event_thread->control.trap_expected' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) y This is a bug, please report it. For instructions, see: <http://www.gnu.org/software/gdb/bugs/>. ../../../../src/gdb-8.0.1/gdb/infrun.c:5575: internal-error: int finish_step_over(execution_control_state*): Assertion `ecs->event_thread->control.trap_expected' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Create a core file of GDB? (y or n) n ``` In the session above the error raised on the second work submitting (the first iteration of the loop was OK). I tried different compiler version (7.1, 7.2 and 7.3) with different thread models of the runtime (posix and win-32); different version of GDB (8.0.1, 8.1 and 7.9 shipped with Intel C++ compiler (gdb-ia)) and I always got the same result -- internal error of GDB. And now I cannot debug my program without ugly workarounds... Any help will be appreciated. Thanks! [1] https://msdn.microsoft.com/en-us/library/windows/desktop/ms686766(v=vs.85).aspx "Thread Pool API" ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
