0

Question: Is it possible that windbg interfere (with byte allocating?) and cause crashing only in debug mode? If so, how?

This question is not specific to any library or opengl, they are specified just for the sake of a solid example.

Example

After a whole day, I can finally narrow down cause of a hilarious strange bug.
Here are my test cases :-

Debug mode & windbg.exe -> crash (GL_OUT_OF_MEMORY_ERROR)
Release mode & windbg.exe -> ok
Debug mode & not use windbg.exe -> ok
Release mode & not use windbg.exe -> ok

Note that "windbg" is enabled only for page heap corruption detection.

Clue: The error occured when I allocate/use byte buffers.
I am not so sure because it was done by an external library (Ogre3D).

javaLover
  • 6,347
  • 2
  • 22
  • 67
  • 2
    Use the -hd flag to [turn off the debug heap](https://msdn.microsoft.com/en-us/library/windows/hardware/ff561306(v=vs.85).aspx) – Raymond Chen Aug 30 '16 at 02:36
  • Possible duplicate of [VS2012 compiler Strange memory deallocation issues](http://stackoverflow.com/questions/18745968/vs2012-compiler-strange-memory-deallocation-issues) – Raymond Chen Aug 30 '16 at 02:39
  • @Raymond Chen Is it same as gflag.exe -> uncheck "Enable page heap" ? – javaLover Aug 30 '16 at 02:40
  • Nope. Debug heap is not the same as page heap. – Raymond Chen Aug 30 '16 at 02:41
  • From the link, I have tried to set ......... project property -> Configuration Property -> Debugging -> Environment :- _NO_DEBUG_HEAP=1 .......... it didn't change any result. But thank, it is a useful-and-related link. – javaLover Aug 30 '16 at 03:48
  • 1
    As noted, you have to use the -hd flag when running windbg. – Raymond Chen Aug 30 '16 at 05:00
  • 1
    Seems somewhat evident what the real problem is, Raymond's comments obfuscate the issue. When you enable page heap verification with gflags then every allocation in your program burns up at least 8096 bytes. At least one page for the allocation and an unmapped one to detect overruns. You'll of course exhaust the available address space in a hurry in a not-so-trivial program, OOM is quite normal. So stop using gflags and do **not** disable the debug heap, it is a terrific bug catcher that doesn't nearly eat up so much memory. – Hans Passant Aug 30 '16 at 08:02
  • @Raymond Chen Sorry for a newbie question, but how I can add "-hd" flag? I ran windbg.exe from Visual Studio via "Debug > Start diagnostic tool > memory", i.e. I didn't open the windbg.exe directly by myself. – javaLover Aug 30 '16 at 09:59

0 Answers0