我最近将高度线程化的非托管Win32 C++控制台应用程序(MediaServer.exe)转换为非托管Win32 DLL(MediaServer.dll)。我在一个单独的非托管Win32控制台应用程序中托管和调试此DLL,并且所有内容都会编译并运行,但一分钟左右后,我会随机发生崩溃,在一个毫无意义的地方发生,并显示一个显然已损坏的调用叠加。这些崩溃发生在各种不同的地方,并且在某些随机时间发生:但通用性是(显然已损坏的)调用堆栈总是在其上某处存在各种libxml2.dll函数,例如,崩溃可能在看起来像一条线像这样:将C++/Win32控制台应用程序转换为DLL后崩溃
xmlDoc * document = xmlReadMemory(message.c_str(), message.length(), "noname.xml", NULL, 0);
或者这样:
xmlBufferPtr buffer = xmlBufferCreate();
且调用栈可能是这样的:
feeefeee()
libxml2.dll!000eeec9()
[Frames below may be incorrect and/or missing, no symbols loaded for libxml2.dll]
libxml2.dll!00131714()
libxml2.dll!001466b6()
libxml2.dll!00146bf9()
libxml2.dll!00146c3c()
libxml2.dll!0018419e()
或者,如果你是幸运的,就像这样:
[email protected]() + 0x99 bytes
[email protected]() - 0x15658 bytes
libxml2.dll!1004dc6d()
[Frames below may be incorrect and/or missing, no symbols loaded for libxml2.dll]
libxml2.dll!10012034()
libxml2.dll!1004b7f7()
libxml2.dll!1003904c()
libxml2.dll!100393a9()
libxml2.dll!10024621()
libxml2.dll!10036e8f()
MediaServer.dll!Controller::parse(std::basic_string<char,std::char_traits<char>,std::allocator<char> > message) Line 145 + 0x20 bytes C++
MediaServer.dll!Controller::receiveCommands() Line 90 + 0x25 bytes C++
MediaServer.dll!MediaServer::processCommands() Line 88 + 0xb bytes C++
MediaServer.dll!MediaServer::processCommandsFunction(void * mediaServerInstance) Line 450 + 0x8 bytes C++
MediaServer.dll!CustomThread::callThreadFunction() Line 79 + 0x11 bytes C++
MediaServer.dll!threadFunctionCallback(void * threadInstance) Line 10 + 0x8 bytes C++
[email protected]@12() + 0x12 bytes
[email protected]() + 0x27 bytes
[email protected]() + 0x1b bytes
崩溃本身通常会这样说: “在0x77cd2239(ntdll.dll中)在MediaServerConsole.exe未处理的异常:0xC000005:访问冲突写入位置0x00000014。”
不用说,当我编译模块作为控制台应用程序时,没有发生这种情况。
将项目转换为DLL时,可能忽略了什么?这不是我以前做过的事情,所以如果有什么明显的我忽略了,我不会感到惊讶。任何帮助表示赞赏。
您是否尝试过在运行任何[本主题]中的建议程序(http://stackoverflow.com/questions/413477/is-there-a-good-valgrind-substitute-for-windows)? Purify,Insure ++等可以帮助您追踪程序中的细微错误。 –
还没有,但我现在正在下载Visual Leak Detector,看它是否可以确定任何事物。 (推测它不在Purify或Insure ++的同一级别,但它是免费的......) –
什么导致了崩溃?访问违规?我假设是,因为释放的堆标有0xFEEFEEE。这听起来像你的堆栈溢出或你的堆已损坏。此外,您可以检查DLL链接的CRT(静态/动态,调试/发布) –