How to generate a dump file by using process orphaning on IIS 6/7.x

 

There is a KB article about How to generate a dump file when ASP.NET deadlocks in IIS 6.0. Please refer to https://support.microsoft.com/kb/828222 . This is not only applied to deadlock issue in IIS 6. Some errors only happen in a production environment. Killing worker processes ensures up-time but troubleshooting of these errors becomes difficult, e.g. if the failing worker process needs to be debugged. The process orphaning feature in WAS allows worker processes to be recycled without killing the failed worker process. Now a debugger can be attached to it. Additional process orphaning settings allow the execution of a process (e.g. a debugger) if orphaning happens.

Download Debugging Tools for Window(WinDbg)

You can download and install Windbg by installing WDK according to your system version from the link as below.

https://msdn.microsoft.com/en-us/windows/hardware/hh852365

Create a batch file to execute when a worker process is orphaned

  1. Start Notepad
  2. Paste the following code into Notepad.
 @if "%_echo%"=="" echo off
 setlocal
     set TIMESTAMP=%DATE:~-9%_%TIME%
 set TIMESTAMP=%TIMESTAMP:/=_%
 set TIMESTAMP=%TIMESTAMP::=_%
 set TIMESTAMP=%TIMESTAMP:.=_%
 set TIMESTAMP=%TIMESTAMP: =_%
 set FILENAME=c:\crash_PID_%1_%TIMESTAMP%.dmp
 set LOG=c:\log.txt
 set COMMAND=c:\debuggers\cdb.exe -c ".dump /o /ma %FILENAME%;q" -p %1
  
 echo %COMMAND% > %LOG%
 %COMMAND%
  endlocal
  1. Save the file as action.cmd to "c:\action.cmd" or other path. 

Note You may have to modify the location of the debuggers and the location where you want the resulting dump file to be generated.

Configure the Orphan Worker Process settings

For IIS 6, you can configure process orphaning as below.

  1. At the command prompt, type the following command, and then press ENTER:
 cd \Inetpub\adminscripts
  1. To enable the Orphan Worker Process feature, type the following command at the command prompt:

Note: Replace the DefaultAppPool as the Problematic application pool name.

 adsutil.vbs SET W3SVC/AppPools/DefaultAppPool/OrphanWorkerProcess TRUE
  1. At the command prompt, set the executable to run when a process is scheduled to be recycled. For example, in this case use the batch file that was created in the "Create a Batch File to Execute When a Worker Process Is Orphaned" section:
 adsutil.vbs SET W3SVC/AppPools/DefaultAppPool/OrphanActionExe "c:\action.cmd"
 adsutil.vbs SET W3SVC/AppPools/DefaultAppPool/OrphanActionParams "%1%"
  

Note Make sure that the OrphanActionExe option points to the location of the batch file that was created in the "Create a Batch File to Execute When a Worker Process Is Orphaned" section. Also make sure that the identity of the W3wp.exe process has Read and Execute permissions to this file.

 

For IIS7 or above version, you can open IIS Manager to configure this feature directly.

1. Select your application pool and click Advanced Settings as below.

 

 

2. Then you can set the Process Orphaning parameters here.

 

Note Make sure that the Executable option points to the location of the batch file that was created in the "Create a Batch File to Execute When a Worker Process Is Orphaned" section. Also make sure that the identity of the W3wp.exe process has Read and Execute permissions to this file.

 

Charles from APGC DSI Team