Release version crashes, debug version runs as expected
Hi,
I have a strange problem. I have an app that uses threads to do some lengthy computations (triggered by some user interaction). These threads can be manipulated by the user by further user interactions.
When I compile the app in debug mode the application runs as expected - I can start one of these threads and then press keys to alter their operation. When I compile in release mode, however, trying to manipulate the thread causes an application crash.
Has any one had this kind of issue before, does anyone have an idea of why debug and release would create different behaviors like this?
I'm using QT4.1 on Mac OS X
Thanks
-Kaushik
Re: Release version crashes, debug version runs as expected
You have somewhere "undefined behaviour".
Undefined can mean: crashes now and then, or crashes in release but not debug build, or vice versa. So it is pure (bad) luck that the crash does not happen in the debug build.
Likely causes:
* thread not synced properly (a accesses to common data protected by a mutex?)
* array bounds violation
Try running your program through valgrind. Maybe you get a hint from there.
HTH
Re: Release version crashes, debug version runs as expected
It could be an uninitialized variable which gets initialized to a sane value in debug mode.
Re: Release version crashes, debug version runs as expected
This is called the Heisenberg Principle. It origins from physics (see the wikipedia entry: http://en.wikipedia.org/wiki/Uncertainty_principle). The idea is that when want to measure a system, you insert a probe to measure it, and thus you change the system. It applies to software as well (read the Popular culture part of the wikipedia entry for more "implementations" of this principle).
The application crashes due to a race condition, you put a which changes the internal timings (or compile in debug mode, which might be slower, faster, or just different), different commands get scheduled differently - oops, no problem :p
Now the fun part of my responce: good luck, you will need it.
Re: Release version crashes, debug version runs as expected
I have a similar problem. Works on debug, but no on release. To make it special, this happens on linux. On windows it's the other way around. I've yet to find any reason for this behavior. My solution ends up being this:
win32 {
CONFIG += release
}
linux-g++ {
CONFIG += debug
}
I also run strip on the app on linux to get a smaller size for it. It's not always 0s and 1s...
Good luck, but don't wast to much time on this quest. It might not be worth it.