Unsolved Optimization in debug mode using or not debugging
-
Hi,
recently I have imported in my project a particular algorithm that was already written on an old project. After a lot of testing where I only used the debugger I tried to run the program without it. What I noticed is that it's behaviour is different: when I use the debugger everything works perfectly but when I simply run the program the output is different. It looks like there is a sort of optimization if I run without the debugger.
For both I'am workoing on debug mode, I am not talking about debug and release mode.Is it something somebody has already run into? Do you have any advice?
I'm working on windows 10 using Qt 5.9.1 MinGW 32 bit.
-
@davidesalvetti said in Optimization in debug mode using or not debugging:
output is different
In what way? It is hard to guess without more information.
-
@jsulm sorry for not mention that.
I have a QVector array that is filled inside the algorithm. If I launch the app with the debugger I get some values that I know are correct. But when I run it without the debugger I get a lot of values more. Let's say with debugger I get 3 values that are correct and without it I get 12 values that are not correct.
So I thought that there must be a difference when I run a program with debugger and when I run it without it.
Unfortunately I cannot put the algorithm here for a matter of copyright, I know that this is not so much...Is there some optimization when debugging or some other option that is different and that i can check? Honestly it's not the first time that variables behave different when in debugging.
-
Any suggestion?
-
@davidesalvetti No, without source code I can't tell.
Usually such issues are caused by not initialised variables (behaviour is different between debug and release builds). So, check your code for such issues. -
Hi
Since you mention its always a debug build, then the normal suspects between release/debug does not apply.
However, debugging can alter the normal timings of the app so it can be related to anything you do asynchronous like with a timer or thread. -
You mention that " with debugger I get 3 values that are correct and without it I get 12 values that are not correct." Does this mean that the algorithm always outputs a certain fraction of values that are correct and the rest is wrong? If yes, where does the randomness come from? Is there some random-call in there or indirectly from a race condition or something?
-
@gde23 thanks for your answer.
I don't have threads or QTimer so I would exclude race conditions. The algorithm is executed in the main thread and is executed from the beginning till the end, that's why it's really strange and I can't understand this difference between using the debugger or not.