DLL Problem !!! Plz help
-
I have created a regular dll which export the function __declspec(dllexport) BOOL Extract(PCLTextList *pList); A create and pass to the dll the pList pointer from a Dialog Based application . When I call delete PList from this app an ASSERTION FAILED Error appears at this function: _CrtIsValidHeapPointer Does anyone know why? Plese help if you can Thanks Jancsi xxx
-
I have created a regular dll which export the function __declspec(dllexport) BOOL Extract(PCLTextList *pList); A create and pass to the dll the pList pointer from a Dialog Based application . When I call delete PList from this app an ASSERTION FAILED Error appears at this function: _CrtIsValidHeapPointer Does anyone know why? Plese help if you can Thanks Jancsi xxx
Correct me if i am wrong: someone creates a list object , sends it to your dll and you fail to delete that object. If that so, then check whether your run-time library and the caller run-time library are the same. For example, if your run-time library is Multithread Dll (/MD) and the caller run-time library is Multithread (/Mt). Check what happens when the caller's project and your project have the same run-time library. Dudi
-
Correct me if i am wrong: someone creates a list object , sends it to your dll and you fail to delete that object. If that so, then check whether your run-time library and the caller run-time library are the same. For example, if your run-time library is Multithread Dll (/MD) and the caller run-time library is Multithread (/Mt). Check what happens when the caller's project and your project have the same run-time library. Dudi
Dudi Avramov wrote: Correct me if i am wrong: someone creates a list object , sends it to your dll and you fail to delete that object. If that so, then check whether your run-time library and the caller run-time library are the same. For example, if your run-time library is Multithread Dll (/MD) and the caller run-time library is Multithread (/Mt). Check what happens when the caller's project and your project have the same run-time library. Uh, oh - this works only if both the .dll and the .exe use the same DLL-Version of the CRT. It will fail if they are linked against the static version. The reason is the following: The CRT contains a heap manager, which implements operators new and delete. If you link the CRT statically to a module (.exe or .dll) the heap manager is also linked to your module, meaning that each module contains its own heap manager. It is not possible to allocate memory from one heap manager and delete it with another one - they don't know of each other and the memory just looks invalid to them. And this is what happens in your project. However, if both, the .dll and the .exe are linked to the same DLL-Version of CRT, they share the same heap manager (because the CRT DLL is loaded only once into the process' address space). Then all ressources (memory, open file handles, etc.) are interchangeable between the modules. To avoid this messy details it is common and good practise to destroy resources always in the same module they have been allocated. Then the used CRT version does not matter and you are always on the safe side :-) -- Daniel Lohmann http://www.losoft.de