Qt application and Google Breakpad

1.7k views Asked by At

I am currently working with an application trying to integrate BreakPad into a Qt application. I found a page that helped me out a bunch with the initial setup and quirks.

https://github.com/JPNaude/dev_notes/wiki/Using-Google-Breakpad-with-Qt

I still cannot get it to work for actual exceptions. I created a demo application and it is having the same issue. Here are the steps I am following to test. I am testing in debug right now.

  1. Build the application Run dump_syms.exe BreakpadTest.pdb > BreakpadTest.sym
  2. Run the application and generate a dump file
  3. Run minidump_stackwalk dumpfile.dmp symbols > out.txt 2>&1
  4. Check out.txt for the file path to place the BreakpadTest.sym
  5. Move the BreakpadTest.sym file to the proper location
  6. Run minidump_stackwalk dumpfile.dmp symbols > out.txt 2>&1 again

This leaves me with an out.txt file.

When I call dumpFunc in my demo application which executes this code

Breakpad::CrashHandler::instance()->writeMinidump();

I get the folowing output

Thread 0 (crashed)
 0  BreakpadTest.exe!Breakpad::CrashHandler::writeMinidump() [crashhandler.cpp : 118 + 0xb]
    eip = 0x00c03a44   esp = 0x00affe18   ebp = 0x00affe48   ebx = 0x009fe000
    esi = 0x00c01960   edi = 0x00c01960   eax = 0x00affaf0   ecx = 0x00affaf0
    edx = 0x00affdbc   efl = 0x00000216
    Found by: given as instruction pointer in context
 1  BreakpadTest.exe!dumpFunc() [main.cpp : 13 + 0xb]
    eip = 0x00c0364f   esp = 0x00affe50   ebp = 0x00affe50
    Found by: call frame info
 2  BreakpadTest.exe!main [main.cpp : 25 + 0x4]
    eip = 0x00c03746   esp = 0x00affe58   ebp = 0x00affea0
    Found by: call frame info
 3  BreakpadTest.exe!WinMain [qtmain_win.cpp : 113 + 0xc]
    eip = 0x00c14d3d   esp = 0x00affea8   ebp = 0x00affed4
    Found by: call frame info
 4  BreakpadTest.exe!invoke_main [exe_common.inl : 94 + 0x1a]
    eip = 0x00c13b7e   esp = 0x00affedc   ebp = 0x00affeec
    Found by: call frame info
 5  BreakpadTest.exe!__scrt_common_main_seh [exe_common.inl : 253 + 0x4]
    eip = 0x00c13a00   esp = 0x00affef4   ebp = 0x00afff44
    Found by: call frame info
 6  BreakpadTest.exe!__scrt_common_main [exe_common.inl : 295 + 0x4]
    eip = 0x00c1389d   esp = 0x00afff4c   ebp = 0x00afff4c
    Found by: call frame info
 7  BreakpadTest.exe!WinMainCRTStartup [exe_winmain.cpp : 16 + 0x4]
    eip = 0x00c13b98   esp = 0x00afff54   ebp = 0x00afff54
    Found by: call frame info
 8  kernel32.dll + 0x162c3
    eip = 0x76c962c4   esp = 0x00afff5c   ebp = 0x00afff68
    Found by: call frame info
 9  ntdll.dll + 0x60fd8
    eip = 0x77850fd9   esp = 0x00afff70   ebp = 0x00afffb0
    Found by: previous frame's frame pointer
10  ntdll.dll + 0x60fa3
    eip = 0x77850fa4   esp = 0x00afffb8   ebp = 0x00afffc0
    Found by: previous frame's frame pointer

This is good and what I want. But when I actually cause an exception with badFunc().

int *myNull = NULL;
*myNull = 42;

I get the following output

Thread 0 (crashed)
 0  ntdll.dll + 0x6e5fc
    eip = 0x7785e5fc   esp = 0x00eff09c   ebp = 0x00eff10c   ebx = 0x00000001
    esi = 0x00000000   edi = 0x00000368   eax = 0x00000000   ecx = 0x6d278097
    edx = 0x00000000   efl = 0x00000206
    Found by: given as instruction pointer in context
 1  KERNELBASE.dll + 0xcad51
    eip = 0x74d7ad52   esp = 0x00eff114   ebp = 0x00eff120
    Found by: previous frame's frame pointer
 2  BreakpadTest.exe!google_breakpad::ExceptionHandler::WriteMinidumpOnHandlerThread(_EXCEPTION_POINTERS *,MDRawAssertionInfo *) [exception_handler.cc : 720 + 0x11]
    eip = 0x009f72d0   esp = 0x00eff128   ebp = 0x00eff138
    Found by: previous frame's frame pointer
 3  BreakpadTest.exe!google_breakpad::ExceptionHandler::HandleException(_EXCEPTION_POINTERS *) [exception_handler.cc : 504 + 0xd]
    eip = 0x009f6d71   esp = 0x00eff140   ebp = 0x00eff178
    Found by: call frame info
 4  KERNELBASE.dll + 0x15d411
    eip = 0x74e0d412   esp = 0x00eff180   ebp = 0x00eff20c
    Found by: call frame info
 5  ntdll.dll + 0x9e0bc
    eip = 0x7788e0bd   esp = 0x00eff214   ebp = 0x00effa10
    Found by: previous frame's frame pointer
 6  ntdll.dll + 0x60fa3
    eip = 0x77850fa4   esp = 0x00effa18   ebp = 0x00effa20
    Found by: previous frame's frame pointer

This is not the actual stack trace where the exception occurred. Any ideas on what is going wrong or how I can change it to get the actual stack?

Demo Application http://s000.tinyupload.com/?file_id=26352983283926785193

2

There are 2 answers

1
Juan Gonzalez Burgos On

I have been recently down the same rabbit hole as well. Taking resources from many places, I put together everything I found in this repo.

One of the things that might affect the stack output is if the optimization level that you are using to compile your application. It doesn't matter if you force the creation of debug symbols. The stack will sometimes appear incorrect if you apply any optimization, so what you can try is to disable optimization in your Qt project (*.pro file) for your release builds as follows:

CONFIG *= force_debug_info
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO -= -O2
0
Jadamec On

I faced the same problem, callstacks were useless, contained only breakpad functions. Removing the compiler optimizations didn't help.

I managed to fix this by updating very old version of dump_syms.exe, minidump_stackwalk.exe, and placing msdia140.dll next to them to the same folder.

So my project has:

CONFIG *= force_debug_info
QMAKE_CFLAGS_RELEASE += -O2 -MD -Zi
QMAKE_LFLAGS_RELEASE += /INCREMENTAL:NO /DEBUG