Bug 460598 - "Breakpoint insertion failure" when setting breakpoint after getline() on Windows
Summary: "Breakpoint insertion failure" when setting breakpoint after getline() on Win...
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug (show other bugs)
Version: 8.5   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: cdt-debug-inbox@eclipse.org CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-23 08:31 EST by Lars M. CLA
Modified: 2020-09-04 15:18 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars M. CLA 2015-02-23 08:31:33 EST
MinGW GDB dies with at SIGINT

I encounter a reproducible failure of GDB when using MinGW or MinGW-w64 on Windows.

Affects:

* eclipse-cpp-luna-SR1a-win32-x86_64
* stable release: mingw64-x64-4.8.1-release-posix-seh-rev5
* most recent release: mingw64-x86_64-4.9.2-release-posix-seh-rt_v3-rev1
* MinGW from https://sourceforge.net/projects/mingw

C:\mingw32\bin>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
Target: mingw32
Configured with: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.6.2 (GCC)

C:\mingw32\bin>gdb -v
GNU gdb (GDB) 7.4

* Windows 7 64bit

Please note, that there are no issues with this code on Linux.



Test code:

[code]
int main(int argc, char **argv)
{
    string line;
    getline(cin, line);
    printf("your line: %s\n", line.c_str());
    return 0;
}
[/code]



Steps to reproduce:

* Build the code with one of the Toolchains mentioned above (using -std=c++0x)
* Launch the program in debug mode.
* Let it run till getline() is called
* Insert a breakpoint at the printf() line



Actual Result:

The program does not respond to user input, GDB does not respond to interrupt or any other commands. An error is thrown: "Breakpoint installation failed: Breakpoint insertion failure"

Significant lines of GDB output:

[code]
132,543 31-exec-continue --thread 1
132,547 31^running
132,547 *running,thread-id="all"
132,547 (gdb)
134,596 =thread-created,id="2",group-id="i1"
134,598 ~"[New Thread 3880.0x1258]\n"
134,598 *running,thread-id="all"
134,602 ~"\nProgram received signal "
134,602 ~"SIGINT, Interrupt.\n"
134,603 ~"[Switching to Thread 3880.0x1258]\n"
134,605 ~"0x0000000076ca49f2 in KERNEL32!CtrlRoutine () from C:\\Windows\\system32\\kernel32.dll\n"
134,605 *stopped,reason="signal-received",signal-name="SIGINT",signal-meaning="Interrupt",frame={add\
r="0x0000000076ca49f2",func="KERNEL32!CtrlRoutine",args=[],from="C:\\Windows\\system32\\kernel32.dll\
"},thread-id="2",stopped-threads="all"
134,607 =thread-selected,id="2"
134,607 (gdb)
134,607 32-break-insert -f D:\\app\\main.cpp:147
[/code]



Expected Result:

Successfully tested with GDB on CMD:

* Open CMD and change to directory containing the executable
* Start executable and look-up its process number (<PID>)
* Open another CMD and start GDB
* In GDB execute the following commands
[code]
attach <PID>
break D:\\app\\main.cpp:147
continue
[/code]
* Switch to first CMD and enter a line and hit <Enter> key
* Switch back to GDB, you should see sth. like:
[code]
Breakpoint 1, main (argc=1, argv=0x4dfe20)
    at D:\10216_wimbus\sources\serial-interface\app\main.cpp:147
147             printf("your line: %s\n", line.c_str());
[/code]
* Now you can step through the rest of the program by entering step



References:

I selected the Toolchain following the (https://qt-project.org/wiki/MinGW-64-bit) Qt Project recommondations.

I found a mailing list thread that may be related to this issue: (https://eclipse.1072660.n5.nabble.com/target-unexpectedly-stops-on-a-SIGINT-while-setting-breakpoint-on-running-target-td62921.html) target unexpectedly stops on a SIGINT while setting breakpoint on running target.

There is a bug report related to this mailing list thread: (https://bugs.eclipse.org/bugs/show_bug.cgi?id=304721) Bug 304721 - Use GDB async mode for GDB 7.0
I'm not sure if this bug is related.


I posted about this issue in the eclipse forums and asked for confirmation, but after 3 days and no reply I decided to report this as a bug.

Currently to me it looks like developing Windows applications on Windows using MinGW and Eclipse CDT is impossible.

Please tell me if I am doing something wrong.
Comment 1 Thomas Arnbjerg CLA 2016-11-29 07:33:19 EST
I'm also struggling with this one in Eclipse Neon.

I can set break points in the main thread most of the time but as soon as I set break points in a worker thread they fail to register or are simply ignored. The application cannot be interrupted.

In the GDB console i see:
Program received signal SIGINT, Interrupt.
[Switching to Thread 6856.0x1240]
0x00000000773f4bf2 in KERNEL32!CtrlRoutine () from C:\WINDOWS\system32\kernel32.dll


Eclipse details:
Eclipse IDE for C/C++ Developers

Version: Neon.1a Release (4.6.1)
Build id: 20161007-1200

CDT 9.1.0 

gcc (x86_64-posix-seh-rev1, Built by MinGW-W64 project) 6.2.0

GDB details:
GNU gdb (GDB) 7.10.1
Copyright (C) 2015 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".