【问题标题】:Visual Leak Detector Crash视觉泄漏检测器崩溃
【发布时间】:2010-07-03 05:03:53
【问题描述】:

我正在使用 Visual Leak Detector 来检测程序中的内存泄漏。当程序完成运行时,我得到一个由 utility.cpp 中的以下代码触发的断言。当 Visual Leak Detector 的标头从程序中排除时,程序运行并退出,不会发生任何事件。

// Get the *real* 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?

我不确定为什么要触发断言。有人知道在什么情况下可以触发断言吗?

谢谢

【问题讨论】:

  • exportmodule(DLL 的名称)和 importname(函数的名称)的值是多少?可能 Visual Leak Detector 修补了 DLL 的导入表,这可能解释了这个问题。
  • 感谢帕特里克的回复。我无法调试线路本身。一旦我单击某处(任何地方),断言窗口就会消失。大多数时候,我从窗口中听到“错误”声音,甚至没有弹出窗口。现在,我已经远离 VSD,而是选择了标准泄漏检测。不是理想的解决方案,但在这种情况下,我别无选择。
  • 此错误已在最新源代码中修复。

标签: memory memory-leaks ogre3d visual-leak-detector


【解决方案1】:

我正在使用 ogre3d + vld,我遇到了同样的问题! 我用 GetLastError() 调试了错误代码: ERROR_PROC_NOT_FOUND,错误 127:找不到指定的过程。

好消息是,如果您注释掉该断言并重新编译,它可以工作(使用“new char[20]”测试), 但是如果你忘记调用“delete Ogre::Root::getSingletonPtr();”它不会被检测到:(

编辑:要向调试控制台报告断言,您可以使用:

        // 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?

结果将是:

============================================ 导入名称:CoGetMalloc 导出模块:C:\data\projects\Avenon\trunk\source\..\build\Avenon_d.exe 错误代码:127 ============================================ ============================================ 导入名称:CoTaskMemAlloc 导出模块:C:\data\projects\Avenon\trunk\source\..\build\Avenon_d.exe 错误代码:127 ============================================ ============================================ 导入名称:CoTaskMemRealloc 导出模块:C:\data\projects\Avenon\trunk\source\..\build\Avenon_d.exe 错误代码:127 ============================================

【讨论】:

  • 嗨,Sajty,感谢您的回复。你是对的,它确实有效,但是如果 Ogre 的指针被泄露,它们就无法被检测到。它仍然比标准检漏仪好。再次感谢!
  • 更新:它再次随机停止为我工作。我已经针对发布和调试进行了编译并检查了两者(注释掉了断言)并且同样的问题仍然存在。最糟糕的是,一个窗口在消失之前会显示一秒钟,所以我不知道发生了什么。我的调试输出显示: ProjectName.exe 中 0x7589b727 处的第一次机会异常:Microsoft C++ 异常:内存位置 0x003cf2d4 处的 OIS::Exception .. =( ... 非常可悲,因为当它工作时,它会产生奇迹
  • 嗨!我用了很多,我也用过OIS键盘和鼠标,没有崩溃。试一试不使用vld,如果它也抛出异常,那么它不是vld。我使用 windows7 system32 文件夹中的 dbghelp,它是 v6.1.7600.16385
【解决方案2】:

尝试使用不同的调试器来检查泄漏。我会使用deleaker

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-13
    • 2011-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-14
    • 2012-06-11
    相关资源
    最近更新 更多