title: How to Find Code Resulting in Inconsistent Results
body: <p>I have a C++ program that processes images and tracks objects in them, using OpenCV.  For the most part, it works well; however the results that I get are inconsistent.  That is, approximately 10% of the time, I am getting slightly different output values and I cannot figure out why.  I do not have any calls to random; I have run valgrind to look for uninitialized memory; I have run clang-tools static analysis on it.   No luck.  The inconsistent runs have one of several different outputs, so they are not completely random.  </p>
  
  <p>Is there a tool that will show me where two runs diverge?  If I run gprof or maybe cflow, can I compare them and see what was different?  Is there some other tool or process I can use?</p>
  
  <p>Edit:  Thank you for the feedback.  I believe that it is due to threading and a race condition; the suggestion was very helpful.  I am currently using advice from: <a href="https://stackoverflow.com/questions/3135160/ways-to-find-a-race-condition">Ways to Find a Race Condition</a> </p>