Memory Allocation Problem in Debug DLL

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello,
I have a class residing inside of a dll and an exe using that dll. Exe simply creates the class within the dll and call its methods. Everything works fine when compiled in release mode. But if I compile everything (including the OpenCV library my class uses)
in debug mode with MDd flag then I get "Debug Assertion Failed! _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)" error.
All of the binaries involved are using the exact same version of the runtime dlls and everything is compiled on the same computer with VS 2008. As far as I understand (based on my debuggings) the problem is the following:
I am creating an instance of my class using the "new" operator in the exe (under main) then as soon as the constructor of my class does something requiring a memory allocation, memory location of the class itself is overwritten as if both the dll and exe
are using the same memory space but different "next available position to allocate" offsets. Therefore the dll does not see that there was already an allocation done inside of the exe hence overwriting the memory area my class resides. Clearly this causes
a memory problem.
Any idea why can this happen? I tried my best to explain the situation but I can of course provide more info if required.
Thanks in advance.



View the full article
 
Back
Top