1) Without symbols
a) The faulting Stack
The stack backtrace of the thread that caused the Divide-ByZero Exception would look like:
0:001>kvn50
Reloading current modules ..*** ERROR: Symbol file could not be found. Defaulted to export symbols for c:\inetpub\wwwroot\Prod\badext.dll -
...............................................
# ChildEBP RetAddr Args to Child
WARNING: Stack unwind information not available. Following frames may be wrong.
00 0088f708 01151529 00da1e90 00000001 00da1f5c badext!HttpExtensionProc+0x5cf
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\WINNT\System32\inetsrv\wam.dll -
01 0088f728 65d82b06 00da1e90 00da1f5c 00da1e90 badext!HttpExtensionProc+0x1fe
02 0088f770 65d823a2 004077b0 00da2006 00da1e90 wam!SE_TABLE::ReleaseExtension+0xbe8
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\WINNT\system32\RPCRT4.DLL -
03 0088f7b4 77d339c0 00406d40 00000000 000000e1 wam!SE_TABLE::ReleaseExtension+0x484
04 0088f7dc 77d93570 65d8223f 0088f7f8 00000005 RPCRT4!NdrServerInitialize+0x288
05 0088fa54 77d949ac 0009cf10 0009e0b8 0009a1a8 RPCRT4!NdrStubCall2+0x570
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\WINNT\system32\ole32.dll -
06 0088fab8 77b29e7f 0009cf10 0009a1a8 0009e0b8 RPCRT4!CStdStubBuffer_Invoke+0x9e
07 0088fafc 77b29d6e 0009a1a8 000ad01c 0009f100 ole32!HDC_UserMarshal+0x78a
08 0088fb44 77aa7ae7 0009a1a8 000acf30 0009cf10 ole32!HDC_UserMarshal+0x679
09 0088fba8 77aa7a33 0009e0b8 00000000 0009cf10 ole32!CoGetCallContext+0x401
0a 0088fbc4 77b29c89 0009a1a8 00000001 0009cf10 ole32!CoGetCallContext+0x34d
0b 0088fbf4 77b29a89 0009a160 0009e0b8 0009cf10 ole32!HDC_UserMarshal+0x594
0c 0088fcb4 77b2a12c 000b1ba0 00000000 000ad000 ole32!HDC_UserMarshal+0x394
0d 0088fcf4 77d33721 0009a160 000ad000 00079af0 ole32!HDC_UserMarshal+0xa37
0e 0088fd2c 77d33667 77b29f7b 00079af0 0088fe0c RPCRT4!I_RpcFree+0x1ff
0f 0088fd84 77d33579 00000000 00000000 0088fe0c RPCRT4!I_RpcFree+0x145
10 0088fda4 77d48e81 00079af0 00000000 0088fe0c RPCRT4!I_RpcFree+0x57
11 0088fdd4 77d34bc6 00079af0 00079ab4 00000000 RPCRT4!RpcSsDestroyClientContext+0xa6
12 0088fe10 77d346c5 000a3958 00081df8 80030001 RPCRT4!NdrCorrelationFree+0x1120
13 0088fe28 77d422ff 000799f8 0088fe50 000a3958 RPCRT4!NdrCorrelationFree+0xc1f
14 0088ff74 77d420d9 77d42528 00081df8 00070000 RPCRT4!NdrConformantArrayMemorySize+0x4c5
15 0088ffa8 77d424da 00080f10 0088ffec 77e887dd RPCRT4!NdrConformantArrayMemorySize+0x29f
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\WINNT\system32\KERNEL32.DLL -
16 0088ffb4 77e887dd 0007e7b8 00070000 0006f740 RPCRT4!NdrConformantArrayMemorySize+0x6a0
17 0088ffec 00000000 77d424c2 0007e7b8 00000000 KERNEL32!GetModuleFileNameA+0x1d1
In this stack backtrace, it is clear that the culprit is "badext.dll". So it is enough to tell the customer to contact the dll vendor to fix it. If it is an in-house component and the customer would like help
from Microsoft, they should open an advisory case to troubleshoot the issue further.
b) The regiters values
0:001> r
eax=00000001 ebx=00000003 ecx=00000000 edx=00000000 esi=78002041 edi=00407848
eip=011518fa esp=0088f708 ebp=0088f708 iopl=0 nv up ei pl zr na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00010246
badext!HttpExtensionProc+5cf:
011518fa f7f9 idiv ecx
c) The disassmbly code
0:001> u eip
badext!HttpExtensionProc+5cf:
011518fa f7f9 idiv ecx
011518fc eb1e jmp badext!HttpExtensionProc+0x5f1 (0115191c)
011518fe 837d0c02 cmp dword ptr [ebp+0xc],0x2
01151902 7515 jnz badext!HttpExtensionProc+0x5ee (01151919)
01151904 8d450c lea eax,[ebp+0xc] 01151907 50 push eax
01151908 33c0 xor eax,eax
0115190a 50 push eax
2) With symbols including public symbols of "badExt.dll"
First, we need to add the symbol path(company wide symbols) as well as public symbols of our dll a) Using the GUI:
- Click "File"
- Click "Symbol File Path"
- Type in SRV*C:\LabSymbols*\\symbols\symbols;C:\IISDebugLabs\symbols\Pub a
nd hit Enter
b) Using the ".sympath+" command:
.sympath+ SRV*C:\LabSymbols*\\symbols\symbols;C :\IISDebugLabs\symbols\Pub
Note: For more information on setting the symbol path for windbg, please refer to the debugger documentation for the .sympath command. This will describe
the "downstream store" feature that lets you download symbols to a symbol server of your own.
The stack backtrace of the thread that caused the DBZ exception would look like:
0:001> kvn50
# ChildEBP RetAddr Args to Child
00 0088f708 01151529 00da1e90 00000001 00da1f5c badext!doDZ1+0xf
01 0088f728 65d82b06 00da1e90 00da1f5c 00da1e90 badext!HttpExtensionProc+0x1fe
02 0088f73c 65d82a97 00da1e90 00da1f5c 00da1e90 wam!HSE_APPDLL::ExecuteRequest+0x93 (FPO: [1,0,3])
03 0088f770 65d823a2 004077b0 00da2006 00da1e90 wam!WAM::InvokeExtension+0x35 (FPO: [Non-Fpo])
04 0088f7b4 77d339c0 00406d40 00000000 000000e1 wam!WAM::ProcessRequest+0x240 (FPO: [Non-Fpo])
05 0088f7dc 77d93570 65d8223f 0088f7f8 00000005 RPCRT4!Invoke+0x30
06 0088fa54 77d949ac 0009cf10 0009e0b8 0009a1a8 RPCRT4!NdrStubCall2+0x63d (FPO: [Non-Fpo])
07 0088fab8 77b29e7f 0009cf10 0009a1a8 0009e0b8 RPCRT4!CStdStubBuffer_Invoke+0xec (FPO: [Non-Fpo])
08 0088fafc 77b29d6e 0009a1a8 000ad01c 0009f100 ole32!SyncStubInvoke+0x61 (FPO: [Non-Fpo])
09 0088fb44 77aa7ae7 0009a1a8 000acf30 0009cf10 ole32!StubInvoke+0xa8 (FPO: [Non-Fpo])
0a 0088fba8 77aa7a33 0009e0b8 00000000 0009cf10 ole32!CCtxComChnl::ContextInvoke+0xbd (FPO: [Non-Fpo])
0b 0088fbc4 77b29c89 0009a1a8 00000001 0009cf10 ole32!MTAInvoke+0x1a (FPO: [Non-Fpo])
0c 0088fbf4 77b29a89 0009a160 0009e0b8 0009cf10 ole32!AppInvoke+0xb5 (FPO: [Non-Fpo])
0d 0088fcb4 77b2a12c 000b1ba0 00000000 000ad000 ole32!ComInvokeWithLockAndIPID+0x29e (FPO: [Non-Fpo])
0e 0088fcf4 77d33721 0009a160 000ad000 00079af0 ole32!ThreadInvoke+0x1b7 (FPO: [Non-Fpo])
0f 0088fd2c 77d33667 77b29f7b 00079af0 0088fe0c RPCRT4!DispatchToStubInC+0x84 (FPO: [Non-Fpo])
10 0088fd84 77d33579 00000000 00000000 0088fe0c RPCRT4!RPC_INTERFACE::DispatchToStubWorker+0x100 (FPO: [Non-Fpo])
11 0088fda4 77d48e81 00079af0 00000000 0088fe0c RPCRT4!RPC_INTERFACE::DispatchToStub+0x5e (FPO: [Non-Fpo])
12 0088fdd4 77d34bc6 00079af0 00079ab4 00000000 RPCRT4!RPC_INTERFACE::DispatchToStubWithObject+0xa9 (FPO: [Non-Fpo])
13 0088fe10 77d346c5 000a3958 00081df8 80030001 RPCRT4!LRPC_SCALL::DealWithRequestMessage+0x1c6 (FPO: [Non-Fpo])
14 0088fe28 77d422ff 000799f8 0088fe50 000a3958 RPCRT4!LRPC_ADDRESS::DealWithLRPCRequest+0x10c (FPO: [Non-Fpo])
15 0088ff74 77d420d9 77d42528 00081df8 00070000 RPCRT4!LRPC_ADDRESS::ReceiveLotsaCalls+0x1eb (FPO: [Non-Fpo])
16 0088ff78 77d42528 00081df8 00070000 0006f740 RPCRT4!RecvLotsaCallsWrapper+0x9 (FPO: [1,0,0])
17 0088ffa8 77d424da 00080f10 0088ffec 77e887dd RPCRT4!BaseCachedThreadRoutine+0x4f (FPO: [Non-Fpo])
18 0088ffb4 77e887dd 0007e7b8 00070000 0006f740 RPCRT4!ThreadStartRoutine+0x18 (FPO: [Non-Fpo])
19 0088ffec 00000000 77d424c2 0007e7b8 00000000 KERNEL32!BaseThreadStart+0x52 (FPO: [Non-Fpo])
Now, with the public symbols lined up, we see that the last call that caused the Divide-By-Zero Exception was to the function "doDZ1" that was called from the ISAPI extension
entry point "HttpExtensionProc".
Again, In this call stack, it is clear that the culprit is "badext.dll". So it is enough to tell the customer to contact the dll vendor to fix it. If it is an in-house component and the customer would like help
from Microsoft, they should open an advisory case to troubleshoot the issue further.
Advanced Technique
Notice also that the call to our extension was invoked by "wam.dll" (Web Application Manager). It is the component responsible for handing
over any request that needs to be processed by an ISAPI extension.
One way to see the http request passed to our extension is to dump the structure of "pWamExecInfo".
0:006> .frame 3
0:001> .frame3
03 0088f770 65d823a2 wam!WAM::InvokeExtension+0x35 [D:\nt\private\inet\iis\svcs\wam\object\wamobj.cxx @ 913]
0:001> dv
this = 0
psExt = 004077b0
szISADllPath = 00da2006 "c:\inetpub\wwwroot\Prod\badext.dll"
pWamExecInfo = 00da1e90
ret = 0x406d40
0:001> dt pWamExecInfo -r
Local var @ 0x88f780 Type WAM_EXEC_INFO*
0x00da1e90
+0x000 ecb :
+0x000 cbSize : 0x90 +0x004 dwVersion : 0x40000
+0x008 ConnID : 0x00da1e90
+0x00c dwHttpStatusCode : 0xc8
+0x010 lpszLogData : [80] ""
+0x060 lpszMethod : 0x00da1ff0 "GET"
+0x064 lpszQueryString : 0x00da2029 "s=dz1_v1"
+0x068 lpszPathInfo : 0x00da1fdc ""
+0x06c lpszPathTranslated : 0x00da1fdd "c:\inetpub\wwwroot"
+0x070 cbTotalBytes : 0
+0x074 cbAvailable : 0
+0x078 lpbData : (null) +0x07c lpszContentType : 0x00da1ff4 ""
.....
.....
.....
To verify that the symbols are lined up properly for our extension, issue this command.
0:006> lmv mbadext
start end module name 06470000 06475000
badext (pdb symbols) C :\IISDebugLabs\symbols\Pub
Loaded symbol image file: C:\IISDebuglabs\www\App\badext.dll Image path: C:\IISDebuglabs\www\App\badext.dll
Timestamp: Wed Jan 29 18:07:14 2003 (3E385EA2)
Checksum: 0000EBCD
File version: 5.0.0.0
Product version: 5.0.0.0
File flags: 0 (Mask 3F)
File OS: 40004 NT Win32
File type: 2.0 Dll
File date: 00000000.00000000
CompanyName: Microsoft Corporation
ProductName: Internet Information Services
InternalName: badEXT.dll
OriginalFilename: badEXT.dll
ProductVersion: 5.00.0984
FileVersion: 5.00.0984
FileDescription: badEXT Test
LegalCopyright: Copyright (C) Microsoft Corp. 1981-1999
3) with Private Symbols "badExt.dll"
First, we need to add the symbol path(company wide symbols) as well as private symbols of our dll a) Using the GUI:
- Click "File"
- Click "Symbol File Path"
- Type in SRV*C:\LabSymbols*\\symbols\symbols;C:\IISDebugLabs\symbols\Pri a
nd hit Enter
b) Using the ".sympath+" command:
.sympath+ SRV*C:\LabSymbols*\\symbols\symbols;C :\IISDebugLabs\symbols\Pri
The stack backtrace of the thread that caused the DBZ would look like:
0:001> .reload;kvn50
.................................................
# ChildEBP RetAddr Args to Child
00 0088f708 01151529 00da1e90 00000001 00da1f5c badext!doDZ1+0xf (CONV: stdcall) [H:\nT\PRIVATE\inet\iis\svcs\w3\gateways\extDBG\badext.cpp @ 426]
01 0088f728 65d82b06 00da1e90 00da1f5c 00da1e90 badext!HttpExtensionProc+0x1fe (CONV: stdcall) [H:\nT\PRIVATE\inet\iis\svcs\w3\gateways\extDBG\badext.cpp @ 146]
02 0088f73c 65d82a97 00da1e90 00da1f5c 00da1e90 wam!HSE_APPDLL::ExecuteRequest+0x93 (FPO: [1,0,3]) (CONV: thiscall) [D:\nt\private\inet\iis\svcs\wam\object\isplocal.cxx @ 450]
03 0088f770 65d823a2 004077b0 00da2006 00da1e90 wam!WAM::InvokeExtension+0x35 (FPO: [Non-Fpo]) (CONV: thiscall) [D:\nt\private\inet\iis\svcs\wam\object\wamobj.cxx @ 913]
04 0088f7b4 77d339c0 00406d40 00000000 000000e1 wam!WAM::ProcessRequest+0x240 (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\inet\iis\svcs\wam\object\wamobj.cxx @ 643]
05 0088f7dc 77d93570 65d8223f 0088f7f8 00000005 RPCRT4!Invoke+0x30 [..\i386\stubless.asm @ 88]
06 0088fa54 77d949ac 0009cf10 0009e0b8 0009a1a8 RPCRT4!NdrStubCall2+0x63d (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\rpc\ndr20\srvcall.c @ 1724]
07 0088fab8 77b29e7f 0009cf10 0009a1a8 0009e0b8 RPCRT4!CStdStubBuffer_Invoke+0xec (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\rpc\ndr20\stub.c @ 1571]
08 0088fafc 77b29d6e 0009a1a8 000ad01c 0009f100 ole32!SyncStubInvoke+0x61 (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\ole32\com\dcomrem\channelb.cxx @ 1136]
09 0088fb44 77aa7ae7 0009a1a8 000acf30 0009cf10 ole32!StubInvoke+0xa8 (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\ole32\com\dcomrem\channelb.cxx @ 1334]
0a 0088fba8 77aa7a33 0009e0b8 00000000 0009cf10 ole32!CCtxComChnl::ContextInvoke+0xbb (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\ole32\com\dcomrem\ctxchnl.cxx @ 1204]
0b 0088fbc4 77b29c89 0009a1a8 00000001 0009cf10 ole32!MTAInvoke+0x18 (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\ole32\com\dcomrem\callctrl.cxx @ 1952]
0c 0088fbf4 77b29a89 0009a160 0009e0b8 0009cf10 ole32!AppInvoke+0xb5 (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\ole32\com\dcomrem\channelb.cxx @ 1013]
0d 0088fcb4 77b2a12c 000b1ba0 00000000 000ad000 ole32!ComInvokeWithLockAndIPID+0x29e (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\ole32\com\dcomrem\channelb.cxx @ 1578]
0e 0088fcf4 77d33721 0009a160 000ad000 00079af0 ole32!ThreadInvoke+0x1b7 (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\ole32\com\dcomrem\channelb.cxx @ 3835]
0f 0088fd2c 77d33667 77b29f7b 00079af0 0088fe0c RPCRT4!DispatchToStubInC+0x84 (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\rpc\runtime\mtrt\dispatch.c @ 82]
10 0088fd84 77d33579 00000000 00000000 0088fe0c RPCRT4!RPC_INTERFACE::DispatchToStubWorker+0x100 (FPO: [Non-Fpo]) (CONV: thiscall) [D:\nt\private\rpc\runtime\mtrt\hndlsvr.cxx @ 543]
11 0088fda4 77d48e81 00079af0 00000000 0088fe0c RPCRT4!RPC_INTERFACE::DispatchToStub+0x5e (FPO: [Non-Fpo]) (CONV: thiscall) [D:\nt\private\rpc\runtime\mtrt\hndlsvr.cxx @ 407]
12 0088fdd4 77d34bc6 00079af0 00079ab4 00000000 RPCRT4!RPC_INTERFACE::DispatchToStubWithObject+0xa9 (FPO: [Non-Fpo]) (CONV: thiscall) [D:\nt\private\rpc\runtime\mtrt\hndlsvr.cxx @ 795]
13 0088fe10 77d346c5 000a3958 00081df8 80030001 RPCRT4!LRPC_SCALL::DealWithRequestMessage+0x1c6 (FPO: [Non-Fpo]) (CONV: thiscall) [D:\nt\private\rpc\runtime\mtrt\lpcsvr.cxx @ 2665]
14 0088fe28 77d422ff 000799f8 0088fe50 000a3958 RPCRT4!LRPC_ADDRESS::DealWithLRPCRequest+0x10c (FPO: [Non-Fpo]) (CONV: thiscall) [D:\nt\private\rpc\runtime\mtrt\lpcsvr.cxx @ 867]
15 0088ff74 77d420d9 77d42528 00081df8 00070000 RPCRT4!LRPC_ADDRESS::ReceiveLotsaCalls+0x1eb (FPO: [Non-Fpo]) (CONV: thiscall) [D:\nt\private\rpc\runtime\mtrt\lpcsvr.cxx @ 1175]
16 0088ff78 77d42528 00081df8 00070000 0006f740 RPCRT4!RecvLotsaCallsWrapper+0x9 (FPO: [1,0,0]) (CONV: stdcall) [D:\nt\private\rpc\runtime\mtrt\lpcsvr.cxx @ 37]
17 0088ffa8 77d424da 00080f10 0088ffec 77e887dd RPCRT4!BaseCachedThreadRoutine+0x4f (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\rpc\runtime\mtrt\hndlsvr.cxx @ 3586]
18 0088ffb4 77e887dd 0007e7b8 00070000 0006f740 RPCRT4!ThreadStartRoutine+0x18 (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\rpc\runtime\mtrt\threads.cxx @ 230]
19 0088ffec 00000000 77d424c2 0007e7b8 00000000 KERNEL32!BaseThreadStart+0x52 (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\windows\base\client\support.c @ 460]
Notice in frame OO and 01 the line of the code as well as the name and location of the source code. Going back to the source code in badext.cpp:
Line 146 looks like
DWORD WINAPI HttpExtensionProc(EXTENSION_CONTROL_BLOCK *lpEcb)
{
.....
.....
if (!strncmp(szS, "av1", 3))
{
return doDZ1(lpEcb, Variation); //Line 146
}
.....
.....
}
Line 426 looks like
DWORD doDZ1(EXTENSION_CONTROL_BLOCK *lpEcb, int Variation)
{
dwThreadID;
HANDLE hThread;
if (Variation == 1)
{
int i = 0;
int j = 1;
j = j / i; //line 426
return j;
}
if (2 == Variation)
{
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DBZ, NULL, 0, &dwThreadID);
}
return HSE_STATUS_SUCCESS;
}