title: Program crashes only in Release mode outside debugger
body: <p>I have quite massive program (>10k lines of C++ code). It works perfectly in debug mode or in release mode when launched from within Visual Studio, but the release mode binary usually crashes when launched manually from the command line (not always!!!).</p>
  
  <p>The line with delete causes the crash:</p>
  
  <pre><code>bool Save(const short* data, unsigned int width, unsigned int height, 
            const wstring* implicit_path, const wstring* name = NULL, 
            bool enable_overlay = false)
  {
      char* buf = new char[17];
      delete [] buf;
  }
  </code></pre>
  
  <p>EDIT: Upon request expanded the example.</p>
  
  <p>The "len" has length 16 in my test case. It doesn't matter, if I do something with the buf or not, it crashes on the delete. </p>
  
  <p>EDIT: The application works fine without the delete [] line, but I suppose it leaks memory then (since the block is never unallocated). The buf in never used after the delete line. It also seems it does not crash with any other type than char. Now I am really confused.</p>
  
  <p>The crash message is very unspecific (typical Windows "xyz.exe has stopped working"). When I click the "Debug the program" option, it enters VS, where the error is specified to be "Access violation writing location xxxxxxxx". It is unable to locate the place of the error though "No symbols were loaded for any stack frame".</p>
  
  <p>I guess it is some pretty serious case of heap corruption, but how to debug this? What should I look for?</p>
  
  <p>Thanks for help.</p>