Program crashes in debugger before anything happens
I'm building an application for Windows XP using the MinGW tool chain and it sometimes crashes unexpectedly. So, I'm trying to use a debugger (Gdb) but the prog开发者_开发问答ram exits with code 03 before anything happens. In fact, all I see from GDB is:
[New thread 3184.0x7b8]
[New thread 3184.0xef8]Program exited with code 03.
My suspicion is that there is some failed dynamic linking of a dependency (which are Qt, VTK, and ITK, all built with MinGW). However, this does not happen when I just run the program normally. Or if it happens, it appears to be intermittent and well after the program is launched and running. NOTE: I'm also using Cmake for cross compiling.
What should I do? What can I try?
Add a callback via signal(SIGABRT, <callback>)
to catch the call to abort before it shuts down the process. If this happens before you hit main()
you might have to resort to a static global and compiler trickery to catch it.
Code 3 is usually returned on a segfault. Try switching to Linux and debugging the program with electric fence. It might give you some extra insight.
精彩评论