I've written an ATL DLL that uses MFC and the CRT.
It works fine in Debug builds, but crashes when it runs in Release builds.
I've noticed, after many hours of disassembly debugging, that if I disable optimization the problem is fixed.
The 'problem' is an access vilation exception. In my code I'm allocating memory into a buffer and trying to access the  item - and getting an exception. I've checked and malloc seemed to work.