I am using Visual Leak Detector to detect memory leaks in my program. When the program has finished running, I get an assertion triggered by the following code in utility.cpp. When Visual Leak Detector's header is excluded from the program, the program runs and exits without incident.
// Get the *re开发者_高级运维al* address of the import. If we find this address in the IAT,
// then we've found that the module does import the named import.
import = GetProcAddress(exportmodule, importname);
assert(import != NULL); // Perhaps the named export module does not actually export the named import?
I am not sure why the assert is being triggered. Does anybody have an idea in what scenarios the assertion can be triggered?
Thanks
I am using ogre3d + vld and I get same issue! I debugged the error code with GetLastError(): ERROR_PROC_NOT_FOUND, error 127: The specified procedure could not be found.
The good thing is, that it works(tested with "new char[20]") if you comment out that assertation and recompile, but if you forget to call "delete Ogre::Root::getSingletonPtr();" it wont be detected :(
Edit: To report assertations to the debug console you can use this:
// Get the *real* address of the import.
import = GetProcAddress(exportmodule, importname);
if(import == NULL){
DWORD err=GetLastError();
WCHAR buff[2048];
wcsncpy_s(buff, 2048, L"\n============================================\nImport name: ", _TRUNCATE);
int i=wcslen(buff);
int n=0;
//cast to unicode
while(importname[n]){
buff[i++]=importname[n++];
}
buff[i]=0;
wcsncat_s(buff, 2048, L"\nExport module: ", _TRUNCATE);
i=wcslen(buff);
GetModuleFileName(exportmodule,&buff[i],2048-i);
wcsncat_s(buff, 2048, L"\nError code: ", _TRUNCATE);
i=wcslen(buff);
_itow_s(err,&buff[i],2048-i,10);
wcsncat_s(buff, 2048, L"\n============================================\n", _TRUNCATE);
report(buff);
}
//assert(import != NULL); // Perhaps the named export module does not actually export the named import?
Result will be:
============================================ Import name: CoGetMalloc Export module: C:\data\projects\Avenon\trunk\source\..\build\Avenon_d.exe Error code: 127 ============================================ ============================================ Import name: CoTaskMemAlloc Export module: C:\data\projects\Avenon\trunk\source\..\build\Avenon_d.exe Error code: 127 ============================================ ============================================ Import name: CoTaskMemRealloc Export module: C:\data\projects\Avenon\trunk\source\..\build\Avenon_d.exe Error code: 127 ============================================
try using a different debugger to check the leak. I would use deleaker
精彩评论