Recently I've occasionally encountered strange breakpoints in Qt Creator when debugging some simple plain C++ programs.
According Qt Creator, The breakpoint occurs in Disassembler (ntdll!DbgBreakPoint). More precisely, in debugger log:
Program received signal
SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 4632.0x13e4]
0x7718000d in ntdll!DbgBreakPoint () from C:\Windows\SysWOW64\ntdll.dll
*stopped,reason="signal-received",signal-name="SIGTRAP",signal-meaning="Trace/breakpoint trap",frame={addr="0x7718000d",func="ntdll!DbgBreakPoint",args=[],from="C:\\Windows\\SysWOW64\\ntdll.dll"},thread-id="2",stopped-threads="all"
NOTE: INFERIOR SPONTANEOUS STOP
Stopped.
State changed from InferiorRunOk(11) to InferiorStopOk(14) [master]
105importPlainDumpers off
SIGTRAP CONSIDERED HARMLESS. CONTINUING.
Stopped: "signal-received".
=thread-selected,id="2"
Thread 2 selected
......
Dump of assembler code for function ntdll!DbgBreakPoint:
0x7718000c <+0>: cc int3
=> 0x7718000d <+1>: c3 ret **where the code breaks**
0x7718000e <+2>: 90 nop
0x7718000f <+3>: 90 nop
0x77180010 <+4>: 90 nop
0x77180011 <+5>: 90 nop
0x77180012 <+6>: 90 nop
0x77180013 <+7>: 90 nop
0x77180014 <+8>: 90 nop
0x77180015 <+9>: 90 nop
0x77180016 <+10>: 90 nop
0x77180017 <+11>: 90 nop
0x77180018 <+12>: 90 nop
0x77180019 <+13>: 90 nop
0x7718001a <+14>: 90 nop
0x7718001b <+15>: 90 nop
0x7718001c <+16>: 90 nop
0x7718001d <+17>: 90 nop
0x7718001e <+18>: 90 nop
0x7718001f <+19>: 90 nop
0x77180020 <+20>: 8b 4c 24 04 mov 0x4(%esp),%ecx
0x77180024 <+24>: f6 41 04 06 testb $0x6,0x4(%ecx)
0x77180028 <+28>: 74 05 je 0x7718002f <ntdll!DbgBreakPoint+35>
0x7718002a <+30>: e8 a1 1d 01 00 call 0x77191dd0 <ntdll!ZwTestAlert>
0x7718002f <+35>: b8 01 00 00 00 mov $0x1,%eax
0x77180034 <+40>: c2 10 00 ret $0x10
0x77180037 <+43>: 90 nop
End of assembler dump.
Program received signal
SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 4632.0x13e4]
0x7718000d in ntdll!DbgBreakPoint () from C:\Windows\SysWOW64\ntdll.dll
*stopped,reason="signal-received",signal-name="SIGTRAP",signal-meaning="Trace/breakpoint trap",frame={addr="0x7718000d",func="ntdll!DbgBreakPoint",args=[],from="C:\\Windows\\SysWOW64\\ntdll.dll"},thread-id="2",stopped-threads="all"
NOTE: INFERIOR SPONTANEOUS STOP
Stopped.
State changed from InferiorRunOk(11) to InferiorStopOk(14) [master]
105importPlainDumpers off
SIGTRAP CONSIDERED HARMLESS. CONTINUING.
Stopped: "signal-received".
=thread-selected,id="2"
Thread 2 selected
......
Dump of assembler code for function ntdll!DbgBreakPoint:
0x7718000c <+0>: cc int3
=> 0x7718000d <+1>: c3 ret **where the code breaks**
0x7718000e <+2>: 90 nop
0x7718000f <+3>: 90 nop
0x77180010 <+4>: 90 nop
0x77180011 <+5>: 90 nop
0x77180012 <+6>: 90 nop
0x77180013 <+7>: 90 nop
0x77180014 <+8>: 90 nop
0x77180015 <+9>: 90 nop
0x77180016 <+10>: 90 nop
0x77180017 <+11>: 90 nop
0x77180018 <+12>: 90 nop
0x77180019 <+13>: 90 nop
0x7718001a <+14>: 90 nop
0x7718001b <+15>: 90 nop
0x7718001c <+16>: 90 nop
0x7718001d <+17>: 90 nop
0x7718001e <+18>: 90 nop
0x7718001f <+19>: 90 nop
0x77180020 <+20>: 8b 4c 24 04 mov 0x4(%esp),%ecx
0x77180024 <+24>: f6 41 04 06 testb $0x6,0x4(%ecx)
0x77180028 <+28>: 74 05 je 0x7718002f <ntdll!DbgBreakPoint+35>
0x7718002a <+30>: e8 a1 1d 01 00 call 0x77191dd0 <ntdll!ZwTestAlert>
0x7718002f <+35>: b8 01 00 00 00 mov $0x1,%eax
0x77180034 <+40>: c2 10 00 ret $0x10
0x77180037 <+43>: 90 nop
End of assembler dump.
To copy to clipboard, switch view to plain text mode
- This behavior only occurs occasionally. I've not found a way to reproduce it consistently.
- The C++ code is VERY simple. Two entire examples shown below.
- This behavior is only observed when debugging the code in Qt Creator (using MinGW 5.3.0 32-bit).
- The breakpoint occurs in a 2nd thread, not the one where the main function is. This 2nd thread seems to only exist when debugging the code.
- I've tried to reproduce this behavior outside of Qt Creator, such as using gdb directly from cmd, but with no success.
- I've read posts/articles on similar problems such as here and here. Both points to heap corruption. However, my example code is SO SIMPLE that I don't see how heap corruption can occur in my code. Or am I missing something extremely basic?
- Qt version 5.7.0 (probably irrelevant)
Qt Creator version 4.1.0
OS: Windows 7 Pro SP1 64-bit
Any comments / suggestions / solutions welcomed.
Thanks in advance!
Example code 1:
#include <vector>
#include <iostream>
using namespace std;
int main()
{
vector<int> v;
for(long long i=0; i<1000000; i++)
v.push_back(i);
cout << v.size() << endl;
}
#include <vector>
#include <iostream>
using namespace std;
int main()
{
vector<int> v;
for(long long i=0; i<1000000; i++)
v.push_back(i);
cout << v.size() << endl;
}
To copy to clipboard, switch view to plain text mode
Example code 2:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream f("..\\fio\\a.txt");
if( !f.is_open() ) {
cerr << "failed to open file" << endl;
exit(EXIT_FAILURE);
}
for(int i=0; i<10000; i++)
f << i << endl;
f.close();
}
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream f("..\\fio\\a.txt");
if( !f.is_open() ) {
cerr << "failed to open file" << endl;
exit(EXIT_FAILURE);
}
for(int i=0; i<10000; i++)
f << i << endl;
f.close();
}
To copy to clipboard, switch view to plain text mode
Bookmarks