I'm having some trouble with memory corruption in a rather large project to control some scientific hardware (ca. 6000 lines), and I'm not sure which is the best way/tool to solve the problem. The project uses Qt 4.8, and it's built with QtCreator and MinGW. The program works more or less, but I'm having some stability issues. Sometimes I get random crashes, but on some occasions, when I change the source code a little bit, the program will crash at exactly the same position (one which has worked previously). The position which it has picked this time looks like this:
char stages2[1024];
sprintf(stages2, "M-511.DD.LOAD\nNOSTAGE");
The second line gives a segmentation fault (SIGSEGV) when I run it in gdb - which tells me that I have some kind of problem with the program's memory, because I'm certain these two lines are correct. Also, the "crash site" changes depending on the exact source code; I've even seen crashes in Windows DLLs which Qt is using.
I've looked into a few options to find the cause of the problem, but I've run into some difficulties:
- I've downloaded DUMA, but I just can't get it to compile on MinGW - I've had to change an include command in order to make the library, but now one of the test programs is failing. (Any hints or links to binaries, anyone?)
- I've also tried Application Verifier, but when I run it it always stops at the same position, where a 3rd party DLL I'm using is leaking a handle. I'm reasonably sure this is not the cause of my problems, but I can't continue the debugging process because gdb always goes back to the same position (it only gets stuck there when I'm using Application verifier).
- Finally, I've run my program with Dr. Memory, but it just crashes before reaching the main window, without giving me any useful outputs (the only thing I'm seeing is where Qt is apparently wasting some memory).
I'd be really grateful for some advice on what's the most promising method to finally get rid of this error.