【发布时间】:2011-08-15 07:28:48
【问题描述】:
我在现场得到了一个由 drwtsn32 生成的故障转储,这表明应用程序在调用系统 API FreeLibrary 时被阻止。 这是类堆栈:
ChildEBP RetAddr Args to Child
06f0fc14 7c827d29 7c83d266 00000718 00000000 ntdll!KiFastSystemCallRet (FPO: [0,0,0])
06f0fc18 7c83d266 00000718 00000000 00000000 ntdll!ZwWaitForSingleObject+0xc (FPO: [3,0,0])
06f0fc54 7c83d2b1 00000718 00000004 00000000 ntdll!RtlpWaitOnCriticalSection+0x1a3 (FPO: [2,7,4])
06f0fc74 7c839874 7c8897a0 00000000 00000000 ntdll!RtlEnterCriticalSection+0xa8 (FPO: [1,1,0])
06f0fd7c 77e6b1bb 014e0000 00000000 02a67430 ntdll!LdrUnloadDll+0x35 (FPO: [SEH])
06f0fd90 005e8cdd 014e0000 02a4bc88 06f0fdbc kernel32!FreeLibrary+0x41 (FPO: [1,0,0])
....
我注意到 ntdll!RtlEnterCriticalSection+0xa8 (FPO: [1,1,0]) 行,我认为这应该是相关的critical_section。所以我在windbg中使用了dt命令来显示它的CRITICAL_SECTION信息
0:037> dt 7c8897a0 RTL_CRITICAL_SECTION
SiteAdminSvc!RTL_CRITICAL_SECTION
+0x000 DebugInfo : 0x7c8897c0 _RTL_CRITICAL_SECTION_DEBUG
+0x004 LockCount : -18
+0x008 RecursionCount : 1
+0x00c OwningThread : 0x00002098
+0x010 LockSemaphore : 0x00000718
+0x014 SpinCount : 0
+0x00c OwningThread : 0x00002098 这一行表明critical_section被线程0x2098持有,但奇怪的是我什至在线程列表中都找不到这样的线程。
还有其他方法可以找出 FreeLibrary 被阻止的原因吗?
PS:还有一个关于挂的故事。如果我使用远程调试器调试应用程序,则不会遇到挂起。但是如果我在服务器机器上启动应用程序。它确实 非常感谢
【问题讨论】:
-
FreeLibrary 在您的程序中的哪个位置调用?你是明确地调用它还是通过“正常”的事情来调用它?
-
FreeLibrary 被显式调用以在不再需要插件模块时卸载它
-
可以显示你在哪里调用它吗?
-
ntdll!RtlpWaitOnCriticalSection+0x1a3 (FPO: [2,7,4]) ntdll!RtlEnterCriticalSection+0xa8 (FPO: [1,1,0]) ntdll!LdrUnloadDll+0x35 (FPO: [SEH] ]) kernel32!FreeLibrary+0x41 (FPO: [1,0,0]) ZQCommonStlp!ZQ::common::DynSharedObj::free+0x1d ZQCommonStlp!ZQ::common::DynSharedObj::~DynSharedObj+0x4d ZQCommonStlp!ZQ ::common::DynSharedObj::`向量删除析构函数'+0x50 SiteAdminSvc!EventSenderManager::DestroyEventSenderEnvironment+0x1d8 上面的堆栈,从代码来看: FreeLibrary 在不再需要时被调用