title: Why does my code crash on ifstream.close? (C++, VS2010)
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6100598/why-would-fclose-hang-deadlock-windows">Why would fclose hang / deadlock? (Windows)</a>  </p>
  </blockquote>
  
  
  
  <p>when i call .close i get a crash. <img src="https://i.stack.imgur.com/CHYDC.png" alt="enter image description here"></p>
  
  <p>What i do is save a file, close it and load it immediately. This is for debugging reasons to see if my serialization code is working (it has many checks and they all pass)</p>
  
  <p>I did some debugging and i cant figure out what may cause it. What i notice is</p>
  
  <ul>
  <li>It crashes on a specific file</li>
  <li>Running the file alone wont crash</li>
  <li>Removing a multiple file will decrease the chance of it from crashing (but i am unsure if it has relevant). From 100% to 50% or 30% depending on how many i remove.</li>
  <li>The less files i have the less likely it will happen. But it always happens on that specific file no matter the amount of files</li>
  <li>Other files crash as well but in a different bat series</li>
  </ul>
  
  <p>But whats bothering me is
  - The file seems to load properly. I put in a debug counter and it is incremented the correct amount of times.
  - The file handle is alive for only one function. The function loads it closes the file and returns the parsed data. Why is it affected by other files in the bat series</p>
  
  <p>In release mode if i run the files in the VS IDE its fine. When i press ctrl F5 to run outside it crashes. But running the single file with release outside of the IDE is fine as well.</p>
  
  <p>I'm very confused.</p>