I have a mixed-mode C++ application (/Clr code with a native library), all compiled with VS 2008.
The Win32 platform build works fine. On the opposite, the x64 build crashes very quickly at application startup.
After laborious debugging, I observe that the creation of a global-scope object in the native library raises a heap corruption assertion (upon "dynamic initializer" invocation).
The code of the object constructor is not the cause.
What can I do ?
It might be that I have solved the issue just by moving the global static variable declarations inside functions.
The problem has apparently disappeared. Hope it is not just because the new memory layout better hides some erratic memory reference...
It is possible, perhaps even likely, that some code that runs before the code that you found is what is causing the problem. That code overwrites the heap and then when your code runs it becomes corrupted due to the previous error.
Be careful of system exceptions that disappear by inexplicable code changes.
Those sorts of code changes modify the execution path - which by its very nature can make the system exception fail to appear WITHOUT fixing the problem.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)