Controling CRT memory initialization

Posted by Ofek Shilon on Stack Overflow See other posts from Stack Overflow or by Ofek Shilon
Published on 2010-05-04T21:56:07Z Indexed on 2010/05/04 21:58 UTC
Read the original article Hit count: 179

Filed under:
|
|

Occasionally you meet bugs that are reproducible only in release builds and/or only on some machines. A common (but by no means only) reason is uninitialized variables, that are subject to random behaviour. E.g, an uninitialized BOOL can be TRUE most of the time, on most machines, but randomly be initialized as FALSE.

What I wish I would have is a systematic way of flushing out such bugs by modifying the behaviour of the CRT memory initialization. I'm well aware of the MS debug CRT magic numbers - at the very least I'd like to have a trigger to turn 0xCDCDCDCD (the pattern that initializes freshly allocated memory) to zeros. I suspect one would be able to easily smoke out nasty initialization pests this way, even in debug builds.

Am I missing an available CRT hook (API, registry key, whatever) that enables this? Anyone has other ideas to get there?

© Stack Overflow or respective owner

Related posts about vc++

Related posts about msvcrt