从挂起分析中获取有关句柄的信息

时间:2015-08-03 09:54:14

标签: windbg handles postmortem-debugging

我在转储文件上有!analyze -hang -v的以下结果。我看到线程0正在等待释放一些句柄,如derived_wait_chain中所指定的那样。如何获得有关此句柄的更多信息? !handle 784.183c会返回错误...

0:000> !analyze -hang -v
*******************************************************************************
*                                                                             *
*                        Exception Analysis                                   *
*                                                                             *
*******************************************************************************


FAULTING_IP: 
+0
00000000 ??              ???

EXCEPTION_RECORD:  ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 00000000
   ExceptionCode: 80000007 (Wake debugger)
  ExceptionFlags: 00000000
NumberParameters: 0

CONTEXT:  00000000 -- (.cxr 0x0;r)
eax=00000000 ebx=00000000 ecx=00000007 edx=00000000 esi=00000003 edi=00000003
eip=7725ca2c esp=0018edc4 ebp=0018ef4c iopl=0         nv up ei pl nz na po nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000202
ntdll!NtWaitForMultipleObjects+0xc:
7725ca2c c21400          ret     14h

BUGCHECK_STR:  HANG

PROCESS_NAME:  scktsrvr.exe

ERROR_CODE: (NTSTATUS) 0xcfffffff - <Unable to get error code text>

EXCEPTION_CODE: (NTSTATUS) 0xcfffffff - <Unable to get error code text>

NTGLOBALFLAG:  0

APPLICATION_VERIFIER_FLAGS:  0

APP:  scktsrvr.exe

ANALYSIS_VERSION: 6.3.9600.17029 (debuggers(dbg).140219-1702) x86fre

DERIVED_WAIT_CHAIN:  

Dl Eid Cid     WaitType
-- --- ------- --------------------------
   0   784.183c Handle                 

WAIT_CHAIN_COMMAND:  ~0s;k;;

BLOCKING_THREAD:  0000183c

DEFAULT_BUCKET_ID:  APPLICATION_HANG_HungIn_ExceptionHandler

PRIMARY_PROBLEM_CLASS:  APPLICATION_HANG_HungIn_ExceptionHandler

PRIMARY_PROBLEM_CLASS_DATA:  .exr 0x18f558 / .cxr 0x18f5a8

LAST_CONTROL_TRANSFER:  from 7534112f to 7725ca2c

FAULTING_THREAD:  00000000

STACK_TEXT:  
0018edc0 7534112f 00000003 0018ef90 00000001 ntdll!NtWaitForMultipleObjects+0xc
0018ef4c 75817b89 00000003 0018ef90 00000000 KERNELBASE!WaitForMultipleObjectsEx+0xcc
0018ef68 758707bf 00000003 0018ef90 00000000 kernel32!WaitForMultipleObjects+0x19
0018f3a8 75870295 00000000 00000001 00000000 kernel32!WerpReportFaultInternal+0x50b
0018f3b8 75851709 0018f44c 753ef705 0018f45c kernel32!WerpReportFault+0x74
0018f3c0 753ef705 0018f45c 00000001 5931c527 kernel32!BasepReportFault+0x19
0018f44c 00403764 0018f45c 772600b1 0018f558 KERNELBASE!UnhandledExceptionFilter+0x1f4
WARNING: Stack unwind information not available. Following frames may be wrong.
0018f478 77260083 0018f558 0018ff74 0018f5a8 scktsrvr+0x3764
0018f540 772607ff 0018f558 0018f5a8 0018f558 ntdll!ExecuteHandler+0x24
0018f540 75344598 0018f558 0018f5a8 0018f558 ntdll!KiUserExceptionDispatcher+0xf
0018f8e8 0046f881 0eedfade 00000001 00000007 KERNELBASE!RaiseException+0x48
0018fefc 0046f987 0018ff4c 0018ff14 0046fa00 scktsrvr+0x6f881
0018ff4c 0046f502 00470bd4 7ffde000 00470ce3 scktsrvr+0x6f987
0018ff80 75817c04 7ffde000 75817be0 599eeb0a scktsrvr+0x6f502
0018ff94 7727ad1f 7ffde000 5b3cddf8 00000000 kernel32!BaseThreadInitThunk+0x24
0018ffdc 7727acea ffffffff 7726024e 00000000 ntdll!__RtlUserThreadStart+0x2f
0018ffec 00000000 00470bd4 7ffde000 00000000 ntdll!_RtlUserThreadStart+0x1b


FOLLOWUP_IP: 
scktsrvr+3764
00403764 83f800          cmp     eax,0

SYMBOL_STACK_INDEX:  7

SYMBOL_NAME:  scktsrvr+3764

FOLLOWUP_NAME:  MachineOwner

MODULE_NAME: scktsrvr

IMAGE_NAME:  scktsrvr.exe

DEBUG_FLR_IMAGE_TIMESTAMP:  2a425e19

STACK_COMMAND:  ~0s ; kb

BUCKET_ID:  HANG_scktsrvr+3764

FAILURE_BUCKET_ID:  APPLICATION_HANG_HungIn_ExceptionHandler_cfffffff_scktsrvr.exe!Unknown

ANALYSIS_SOURCE:  UM

FAILURE_ID_HASH_STRING:  um:application_hang_hungin_exceptionhandler_cfffffff_scktsrvr.exe!unknown

FAILURE_ID_HASH:  {45df6cc2-89e8-d20a-efde-b2365e4d9c6c}

Followup: MachineOwner
---------

1 个答案:

答案 0 :(得分:1)

784是进程ID(PID),183c是线程等待的线程ID(TID)。要获取有关它正在等待的句柄的更多信息,请切换到该线程并获取带有参数(32位为kb)的调用堆栈。这样您就可以拨打WaitForMultipleObjects()WaitForSingleObject(),并从参数中获取它等待的句柄。

在您的情况下,堆栈列为!analyze的一部分:

STACK_TEXT:  
0018edc0 7534112f 00000003 0018ef90 00000001 ntdll!NtWaitForMultipleObjects+0xc
0018ef4c 75817b89 00000003 0018ef90 00000000 KERNELBASE!WaitForMultipleObjectsEx+0xcc
0018ef68 758707bf 00000003 0018ef90 00000000 kernel32!WaitForMultipleObjects+0x19

查看MSDN,它说

DWORD WINAPI WaitForMultipleObjects(
  _In_       DWORD  nCount,
  _In_ const HANDLE *lpHandles,
  _In_       BOOL   bWaitAll,
  _In_       DWORD  dwMilliseconds
);

因此该线程等待3个句柄,在地址0018ef90处有三个句柄,您可以使用!handle获取更多信息。

但是,似乎真正的问题只是隐藏在Windows的“向Microsoft发送错误报告”功能背后。

从参数ntdll!KiUserExceptionDispatcher()(异常记录和异常上下文)中,您可以找到有关原始异常的更多信息。正如@deemok所提到的,.exr 0x18f558.cxr 0x18f5a8应该会提供更多信息。

从参数到KERNELBASE!RaiseException(),异常代码是0x0eedfade,这是Delphi应用程序的典型代码。 Marc Durdin有一篇关于使用WinDbg分析Delphi异常的文章。