I am doing a basic cinder application in Visual Studio. It is a particle generation (loosely following the online Hello Cinder guide. In debug mode it always works. In release configuration however, it sometimes does not generate any particle.
My best guess is there is UB somewhere, the problem is that it is really hard to detect. Small, seemingly unrelated changes can trigger or untrigger this.
For instance, changing in function draw
:
spatial_.speed_ += 0.1f * ci::Vec2f(cos(noise * 15.0f), sin(noise * 15.0f));
// ^^^^^
// this value
any constant value other than 1.0f or the absence of the constant value will cause no particle to be generated. How can a change in the function draw
affect the code in the function update
(where I generate the particles). I know they are not generated at all because I display a particle count.
All sorts of these kind of changes all over the program cause this (like changing constants, changing parameter types from value to reference, adding or removing line that outputs to console()).
I don’t want you guys to debug my code, that’s why I didn’t put code here.
I am just lost on how to deal with this. My question is how should I proceed to diagnose the bug? What are my options, what steps do I have to take from here?
The problems I am facing:
- I have no idea where the bug is in the whole code.
- In debug mode everything works fine
- I can’t debug in release mode (
debugging information for ***.exe cannot be found or does not match. Binary was not build with debug information
) and any break points are whited out in the GUI with the tooltipthe breakpoint will not be currently hit (no symbols have been loaded for this document)
- I can’t debug by printing output because adding the code to display output will make the program work. (How ironic is this?)
- In release mode even if I get it to work (by trial and error, adding/removing lines), if I don’t identify the problem, there is nothing to say that changing something somewhere else will break the code again.
Update:
- CppCheck reports no problems. I’ve manually double checked for uninitialized members/variables.
- I’ve been trying to isolate this thing. The problem is that ANY modification I do will cause the particles to be generated. If I change any code in the
draw
function the particles will be generated. If I delete to code for the size of the particles the particles will be generated. If I delete the code for the motion, the particles will be generated. If I delete the code for drawing the particles, the particles will be generated. If I delete the code for the initial position of the particles, the particles will be generated, if I delete the code that removes the dead particles, the particles get generated. The only thing that I found it maintains the fault is if I change the fps settings, so yeah, I know that setting the fps is not causing the problem, so hurray.