This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/22992] New: GDB and Microsoft Windows thread pool


https://sourceware.org/bugzilla/show_bug.cgi?id=22992

            Bug ID: 22992
           Summary: GDB and Microsoft Windows thread pool
           Product: gdb
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: ruslanngaripov at gmail dot com
  Target Milestone: ---
              Host: Microsoft Windows 10 x86-64
            Target: Microsoft Windows 10 x86-64
             Build: x86_64-w64-mingw32

Created attachment 10906
  --> https://sourceware.org/bugzilla/attachment.cgi?id=10906&action=edit
Sample code

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 comes 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 are being 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 build 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...

This issue was confirmed by Liu Hao on Microsoft Windows 7 x64[2].

[1]:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686766(v=vs.85).aspx
"Thread Pool API"
[2]: https://sourceforge.net/p/mingw-w64/mailman/message/36269973/ "Re:
[Mingw-w64-public] GDB and Microsoft Windows thread pool"

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]