Summary
The UnhandledExceptionFilter function is called when no exception handler is defined to handle the exception that is raised. The function typically passes the exception up to the Ntdll.dll file, which catches and tries to handle it.
In some scenarios in which a memory snapshot of the process exists, you can see that the thread that holds the lock points to a thread that calls the UnhandledExceptionFilter function. In those cases, you can follow the steps in this article to identify the DLL that caused the exception.
Open a Dump File by Using Windbg.exe
- Download and install the debuggers. To download the debuggers, visit the following Microsoft Web site:
Microsoft Debugging Tools
http://www.microsoft.com/whdc/devtools/ddk/default.mspx - Open the folder where you installed the debuggers, and then double-click Windbg.exe to start the debugger.
- On the File menu, click Open Crash Dump (or press CTRL+D), and then select the dump file that you want to view.
Use Windbg.exe to Identify the Exception Stack.
-
In Windbg.exe, open the .dmp file of the process.
-
Make sure that you are pointing the symbol path to a correct location. For more information about how to do this, visit the following Microsoft Web site:
How to Get Symbols
http://www.microsoft.com/whdc/devtools/ddk/default.mspx -
At a command prompt, type ~*kb to list all of the threads in the process.
-
Identify the thread that makes the call to the function Kernel32!UnhandledExceptionFilter. It looks similar to the following:
1 | 120 id: f0f0f0f0.a1c Suspend: 1 Teb 7ff72000 Unfrozen |
-
Switch to that thread (in this example, the thread is “~120s”).
-
Display the memory contents at the location specified by the first parameter of Kernel32!UnhandledExceptionFilter by using dd First Param. This points to the EXCEPTION_POINTERS structure.
···
0:120> dd 09a8f66c
09a8f66c 09a8f738 09a8f754 09a8f698 77f8f45c
09a8f67c 09a8f738 09a8ffdc 09a8f754 09a8f710
09a8f68c 09a8ffdc 77f8f5b5 09a8ffdc 09a8f720
09a8f69c 77f8f3fa 09a8f738 09a8ffdc 09a8f754
09a8f6ac 09a8f710 77e8615b 09a8fad4 00000000
09a8f6bc 09a8f738 74a25336 09a8f6e0 09a8f910
09a8f6cc 01dc8ad8 0d788918 00000001 018d1f28
09a8f6dc 00000001 61746164 7073612e 09a8f71c
··· -
The first DWORD represents the exception record. To obtain information about the type of exception, run the following at a command prompt:
.exr first DWORD from step 6
···
0:120> .exr 09a8f738
ExceptionAddress: 78011f32 (MSVCRT!strnicmp+0x00000092)
ExceptionCode: c0000005
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000000
Parameter[1]: 00000000
Attempt to read from address 00000000
··· -
The second DWORD is the context record. To obtain contextual information, run the following at a command prompt:
.cxr second DWORD from step 6
···
0:120> .cxr 09a8f754
eax=027470ff ebx=7803cb28 ecx=00000000 edx=00000000 esi=00000000 edi=09a8fad4
eip=78011f32 esp=09a8fa20 ebp=09a8fa2c iopl=0 nv up ei ng nz na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010286
MSVCRT!strnicmp+92:
78011f32 8a06 mov al,[esi]
··· -
Run a kv command to get the call stack of the actual exception. This helps you to identify the actual problem in the process that might not have been handled correctly.
1 | 0:120> kv |
References
For more information, see the following books:
- Solomon, David A., and Mark Russinovich. Inside Microsoft Windows 2000, Third Edition (http://www.microsoft.com/mspress/books/4354.asp). Redmond: Microsoft Press, 2000.
- Solomon, David A. Inside Windows NT - Second Edition (Microsoft Programming Series). Redmond: Microsoft Press, 1998.
- Richter, Jeffrey. Programming Applications with Microsoft Windows (http://www.microsoft.com/mspress/books/2345.asp). Redmond: Microsoft Press, 1999.
本文地址:http://xnerv.wang/how-to-find-the-problem-exception-stack-when-you-receive-an-unhandlede/
转载自:HOW TO: Find the Problem Exception Stack When You Receive an UnhandledExceptionFilter Call in the Stack Trace