1) Without symbols
a) The faulting Stack
The stack backtrace of the thread that caused the Divide-ByZero Exception would look like:
0:000> kvn50 #
ChildEBP RetAddr Args to Child WARNING: Stack unwind information not available. Following frames may be wrong.
00 0006fe50 010015c4 0006fe6c 00000001 000851c8 badcgi+0x1956
01 0006ff70 01001daf 00000001 00232468 00232cd8 badcgi+0x15c4
02 0006ffc0 77e9ca90 000851c8 00000000 7ffdf000 badcgi+0x1daf
03 0006fff0 00000000 01001cb0 00000000 000000c8 KERNEL32!BaseProcessStart+0x3d
Keep in mind that we are here debugging a custom CGI application that misbehaved. The web application relying on this CGI will eventually not run properly.
So, in this stack backtrace, it is clear that the culprit is "badCgi.exe". So it is enough to tell the customer to contact the CGI 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:000> r
eax=00000001 ebx=00000003 ecx=00000000 edx=00000000 esi=78002041 edi=002324b0
eip=01001956 esp=0006fe50 ebp=0006fe50 iopl=0 nv up ei pl zr na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000 efl=00000246
badcgi+1956:
01001956 f7f9 idiv ecx
c) The disassmbly code
0:000> u eip
badcgi+1956:
01001956 f7f9 idiv ecx
01001958 eb1e jmp badcgi+0x1978 (01001978)
0100195a 837d0c02 cmp dword ptr [ebp+0xc],0x2
0100195e 7515 jnz badcgi+0x1975 (01001975)
01001960 8d450c lea eax,[ebp+0xc]
01001963 50 push eax
01001964 33c0 xor eax,eax
01001966 50 push eax
2) With symbols including public symbols of "badCgi.exe"
First, we need to add the public symbol path(company wide symbols) as well as 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 and Press Enter
b) Using the ".sympath+" command:
.sympath+ SRV*C:\LabSymbols*\\symbols\symbols;C :\IISDebugLabs\symbols\Pub
0:000> kvn
# ChildEBP RetAddr Args to Child
00 0006fe50 010015c4 0006fe6c 00000001 000851c8 badcgi!doDZ1+0xf
01 0006ff70 01001daf 00000001 00232468 00232cd8 badcgi!main+0x244
02 0006ffc0 77e9ca90 000851c8 00000000 7ffdf000 badcgi!mainCRTStartup+0xff (CONV: cdecl) [crtexe.c @ 338]
03 0006fff0 00000000 01001cb0 00000000 000000c8 KERNEL32!BaseProcessStart+0x3d (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\windows\base\client\support.c @ 504]
Now, with the public symbols lined up, we see that the last call that Caused the DBZ exception is "doDZ1" that was called from the CGI entry point (main)
Again, In this stack backtrace, it is clear that the culprit is "badCgi.exe". 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.
To verify that the symbols are lined up properly for our extension, issue this command.
0:000> lmv mbadcgi
start end module name
01000000 01004000 badcgi (pdb symbols) c:\iisdebuglabs\symbols\pub\badcgi.pdb
Loaded symbol image file: badcgi.exe
Image path: C:\IISDebugLabs\www\app\badcgi.exe
Timestamp: Tue May 13 17:49:56 2003 (3EC16884) Checksum: 0000691D
3) with Private Symbols "badCgi.exe"
First, we need to add the private symbol path(company wide symbols) as well as private symbols of our exe 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:000> kvn
# ChildEBP RetAddr Args to Child
00 0006fe50 010015c4 0006fe6c 00000001 000851c8 badcgi!doDZ1+0xf (CONV: stdcall) [C:\build\nT\PRIVATE\inet\iis\svcs\w3\gateways\cgiDBG\badcgi.cpp @ 429]
01 0006ff70 01001daf 00000001 00232468 00232cd8 badcgi!main+0x244 (CONV: cdecl) [C:\build\nT\PRIVATE\inet\iis\svcs\w3\gateways\cgiDBG\badcgi.cpp @ 162]
02 0006ffc0 77e9ca90 000851c8 00000000 7ffdf000 badcgi!mainCRTStartup+0xff (CONV: cdecl) [crtexe.c @ 338]
03 0006fff0 00000000 01001cb0 00000000 000000c8 KERNEL32!BaseProcessStart+0x3d (FPO: [Non-Fpo]) (CONV: stdcall) [D:\nt\private\windows\base\client\support.c @ 504]
Notice in frame 00 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 badCgi.cpp:
Line 162 looks like
DWORD main( int argc, char * argv[])
{
....
....
else if (!strncmp(szS, "dz1", 3))
{
return doDZ1(rgchQuery, Variation); //Line 162
}
....
....
return (1);
} // main()
Line 429 looks like
DWORD doDZ1(CHAR szQS[DEFAULT_LEN], int Variation)
{
DWORD dwThreadID;
HANDLE hThread;
if (1 == Variation)
{
int i = 0;
int j = 1;
j = j / i;
return j; //line 429
}
if (2 == Variation)
{
HANDLE lpHandles[1];
lpHandles[0] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DBZ, NULL, 0, &dwThreadID);
DWORD dw = WaitForMultipleObjects(1, lpHandles, TRUE, INFINITE);
}
return 1;
}