Detecting deadlocks in a child process

This tutorial describes how to detect deadlocks in a child process of an application.

This tutorial covers the following:

    1. Using the launch dialog to specify the child process to monitor and the instance number of that child process.
    2. How to use the Thread Validator user interface to detect deadlocks in the child process.

Related tutorials:

Detecting deadlocks in a service.
Detecting deadlocks in a service child process.
Detecting deadlocks in an IIS ISAPI DLL.
Detecting deadlocks for a child process from the command line.

Native applications

This tutorial applies to all native applications, services and IIS ISAPI extensions.

Example Application and Child Process Application

Thread Validator ships with an example application and an example child process launched by the application. These can be found in the  following directories in the Thread Validator installation directory:

  • examples\nativeExample
  • examples\serviceWithAChildProcess\childProcess 

You need to build both of these projects. The easiest thing to do is to build the examples.sln.

Detecting deadlocks in the child process

Now that you have the example projects build, we can start detecting deadlocks from the child process.

  1. Choose the Launch > Applications > Launch Application… option.
    Thread Validator launch application menu
  2. The Launch dialog is displayed.
    Thread Validator native launch dialog
  3. Click Browse… next to Application to Launch and choose the executable that is going to launch the process you want to start detecting deadlocks from. You can also choose a batch file or a powershell script. For this tutorial we’re going to start examples\nativeExample\Release10_0_x64\nativeExample_x64.exe.
    Thread Validator native and .Net browse for application
  4. Now we need to specify which child processes will be launched by the parent process. Click Edit… next to Application to Monitor.
    Thread Validator native and .net edit application to monitor
    The Applications to Monitor dialog will be displayed.
    Memory Validator native and .Net applications to monitor dialog
  5. We need to add an application definition. Click Add…. The Application to Monitor dialog will be displayed.
    Memory Validator native and .Net application to monitor dialog
  6. To add an application click Add…. The Application and DLL dialog is displayed.
    Memory Validator native and .Net Application and DLL dialog
  7. Type the path to the child process executable or use the Browse… button to open a Microsoft file dialog to select the child process executable. For this tutorial we’re going to choose the child process executable: examples\nativeExample\Release10_0_x64\childProcess_x64.exe.  
    Thread Validator application and dll native example
  8. Click OK to complete adding the child process definition. Repeat steps 6 and 7 to add as many child process definitions as you need for your process.
  9. When you have added all the child process definitions click OK to close the Application To Monitor dialog.
    For this tutorial we’re only adding one child process definition, so click OK.
  10. Click OK to close the Applications To Monitor dialog.
  11. If you examine the Application to Monitor field on the launch dialog you can see it now has some entries in addition to the name of the file we’re going to launch.
    Thread Validator native and .Net application to monitor combo
  12. Choose the child process in the Application to Monitor field.
    Thread Validator native and .net application to monitor child process
  13. We’re going to monitor the first childProcess_x64.exe that is launched. This is the default, indicated by the 1 in the Launch Count combo below the Application to Monitor field. If you wanted to monitor the third childProcess_x64.exe that is launched you’d set this to 3. 
  14. Now that we’ve specified the process to launch and the child process we can start the Application to Launch.
    Click Launch….
    Thread Validator starts the Application to Launch (in this tutorial that’s nativeExample_x64.exe).
  15. When nativeExample_x64.exe is running choose the Child Process menu then choose Start ChildProcess….
    Thread Validator native and .Net child process
    The child process is started. In this tutorial that’s childProcess_x64.exe.
    For childProcess_x64.exe you’ll see a cmd prompt open, there will be a pause while the application runs, then it will close.
  16. Thread Validator will instrument your applications’s child process and start detecting deadlocks data.
  17. Thread synchronization data will be collected until the child process finishes executing.  For best results, we recommend closing the child process normally (do not kill it with TaskManager or TerminateProcess). 
  18. You can close the parent process whenever you want – Thread Validator is not tracking it.
  19. When the child process finishes executing Thread Validator will display the deadlock detection results.
    Thread Validator native and .Net child process deadlock detection results

How Do I Repeat This?

There are three method of repeating this.

  1. To repeat launching the parent process and monitoring the child process just click the relaunch button on the toolbar.


  2. You can open the launch dialog then double click on an entry in the list at the bottom of the dialog.
    Thread Validator native and .Net launch dialog relaunch
  3. You can open the launch dialog then select an entry in the list at the bottom of the dialog, edit any settings on the dialog, then click Launch.

I need to detect deadlocks in a grand child process or other descendant. How do I do that?

The method described above only works for child processes of a parent process.
If you have a process that is a descendent process deeper than a child process read this article about Loading Validator into an application.

I’m not getting any deadlock detection data. What can I do?

There are a few things to check.

  1. Data Collection
    Have you got data collection turned off?
    There is a Collect data from application check box on the launch dialog.
    There are also data collection on/off buttons on the main toolbar, and Start collecting data and Stop collecting data options on the File menu.
  2. Diagnostics
    Check the diagnostics tab. If the injection and data transport is working correctly Thread Validator will have some data. Information on instrumentation failures will be on the diagnostic tab.
  3. Debug Information
    Check the debug information dialog. You can access this from the Tools > DLL Debug Information… menu. This dialog will tell you which DLLs have debug information and which do not. Any DLLs that don’t have debug information you’ll need to ensure that debug information is built for these DLLs and is findable.


You have learned how to launch an application and monitor a child process launched by that application, how to use Thread Validator to monitor the application’s child process, and what to look at to diagnose errors if things don’t work first time.



Fully functional, free for 30 days