代碼:
0:000:x86> kb
ChildEBP RetAddr Args to Child
0032dd0c 779ed993 00000710 00000000 00000000 ntdll_779b0000!NtWaitForSingleObject+0x15
0032dd70 779ed877 00000000 00000000 024023f0 ntdll_779b0000!RtlpWaitOnCriticalSection+0x13e
0032dd98 58a2fac3 02404c50 856fd57e 024023f0 ntdll_779b0000!RtlEnterCriticalSection+0x150
0032dffc 58a0d4d7 856fea8a 00000000 001c41a0 SogouSoftware_589d0000!CDownloadListUI::UpdateDownloadListUI+0x43
代碼:
0:000:x86> !cs 02404c50
-----------------------------------------
Critical section = 0x0000000002404c50 (+0x2404C50)
DebugInfo = 0x0000000000611e08
LOCKED
LockCount = 0xFFFFFFFF
WaiterWoken = Yes
OwningThread = 0x0000000000000710
RecursionCount = 0x1A38
LockSemaphore = 0x2433B08
SpinCount = 0x0000000000000000
代碼:
0:000:x86> ~~[710]
^ Illegal thread error in '~~[710]'
代碼:
void CDownloadListUI::UpdateDownloadListUI()
{
m_vctLock.Lock();
vector<int> vecDeleteItems(GetCount()); // record index to be delete
std::iota(vecDeleteItems.begin(), vecDeleteItems.end(), 0);
......
m_vctLock.UnLock();
}
代碼:
0:000:x86> dt _RTL_CRITICAL_SECTION 02404c50
DuiLib!_RTL_CRITICAL_SECTION
+0x000 DebugInfo : 0x00611e08 _RTL_CRITICAL_SECTION_DEBUG
+0x004 LockCount : 0n-6
+0x008 RecursionCount : 0n1
+0x00c OwningThread : 0x00001a38 Void
+0x010 LockSemaphore : 0x00000710 Void
+0x014 SpinCount : 0
代碼:
0:000:x86> ~~[1a38]
6 Id: 2058.1a38 Suspend: 0 Teb: 7ef94000 Unfrozen
Start: SogouSoftware_589d0000!_threadstartex (58a5192d)
Priority: 0 Priority class: 32 Affinity: f
0:000:x86> ~6s
ntdll_779b0000!ZwWaitForMultipleObjects+0x15:
779d019d 83c404 add esp,4
0:006:x86> kb
ChildEBP RetAddr Args to Child
0370fa5c 768615f7 00000002 0370faac 00000001 ntdll_779b0000!ZwWaitForMultipleObjects+0x15
0370faf8 773519f8 0370faac 0370fb20 00000000 KERNELBASE!WaitForMultipleObjectsEx+0x100
0370fb40 773541d8 00000002 7efde000 00000000 kernel32!WaitForMultipleObjectsExImplementation+0xe0
0370fb5c 589f6ba0 00000002 0370fb84 00000000 kernel32!WaitForMultipleObjects+0x18
0370fbd4 58a51907 58aab894 862df68e 00000000 SogouSoftware_589d0000!CThreadQueue<TagDownloadTask>::ThreadProc+0x100
0370fc0c 58a51991 00000000 0370fc24 7735336a SogouSoftware_589d0000!_callthreadstartex+0x1b [f:\dd\vctools\crt_bld\self_x86\crt\src\threadex.c @ 314]
0370fc18 7735336a 023f5170 0370fc64 779e9882 SogouSoftware_589d0000!_threadstartex+0x64 [f:\dd\vctools\crt_bld\self_x86\crt\src\threadex.c @ 292]
0370fc24 779e9882 023f5170 771cc6bb 00000000 kernel32!BaseThreadInitThunk+0xe
0370fc64 779e9855 58a5192d 023f5170 00000000 ntdll_779b0000!__RtlUserThreadStart+0x70
0370fc7c 00000000 58a5192d 023f5170 00000000 ntdll_779b0000!_RtlUserThreadStart+0x1b
但 !cs 命令在此種情況下卻給出了錯誤的信息,很容易造成誤導而懷疑是一個擁有該鎖的線程退出了而引起的。這應該算是Windbg的一個bug吧。
進一步測試該情況,發現是當64位系統下的32位進程產生的dump會有此問題,32位系統下產生的dump使用 !cs 命令執行正常。