Tim
Tim

Reputation: 23

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 program 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?

Upvotes: 2

Views: 538

Answers (2)

MSN
MSN

Reputation: 54604

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.

Upvotes: 2

mingos
mingos

Reputation: 24502

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.

Upvotes: 0

Related Questions