title: Unkillable processes often hang for a long time
body: <p>Since re-installing Windows 7 Ultimate 64-bit SP1, sometimes processes take a long time to close.  This happens most frequently when launching them from VS2010, but it's not limited to that.  A common case is a Windows app with a console (/SUBSYSTEM:console) that appears to close correctly, but the console remains open for seconds or minutes.  Eventually the "press any key to close" message appears on the console, and the process can be terminated.</p>
  
  <p><strong>How can I diagnose this problem?</strong></p>
  
  <ul>
  <li>I installed Windows 7 Ultimate 64-bit SP1, but this time the vanilla (not <em>N</em>) version</li>
  <li>The only driver I manually installed is the NVIDIA display driver, but I've tried multiple WHQL versions</li>
  <li>The symptoms closely match the question at
  <a href="https://stackoverflow.com/questions/2402875/visual-studio-debug-console-sometimes-stays-open-and-is-impossible-to-close">Visual studio debug console sometimes stays open and is impossible to close</a>  <strong>Even non-console apps are affected, however.</strong></li>
  <li>Both native and managed applications suffer from this.</li>
  <li>WRONG: I believed only 32-bit processes were affected, but 64-bit ones also suffer.</li>
  <li>if a debugger is already attached, and I break while the process is waiting, the debugger
  says:  </li>
  </ul>
  
  <blockquote>
    <p>The process appears to be deadlocked (or is not running any<br>
    user-mode code).  All threads have been stopped.</p>
  </blockquote>
  
  <ul>
  <li>I can't attach a debugger to a process while its in this state</li>
  <li>I can't kill these zombie processes from Task Manager or
  ProcessExplorer, even when closing all handles that refer to said
  processes. (I can't close lsass.exe's handles, though)</li>
  </ul>
  
  <hr>
  
  <ul>
  <li>ProcessExplorer says that the hanging function of the only thread
  that the each hung process has is <strong>ntdll!RtlDosSearchPath_Ustr.</strong></li>
  </ul>
  
  <hr>
  
  <ul>
  <li>Most of the time I have to close Visual Studio completely to allow
  the zombie processes to close.</li>
  <li>The last event that Process Monitor sees at the hang in each case is
  a Thread Exit, which succeeds, and it looks like the exit takes the
  normal amount of time.  When the process finally closes, no events
  show up.</li>
  <li>LiveKd doesn't show anything when I follow the steps outlined at
  <a href="http://blogs.technet.com/b/markrussinovich/archive/2005/08/17/unkillable-processes.aspx" rel="nofollow noreferrer">http://blogs.technet.com/b/markrussinovich/archive/2005/08/17/unkillable-processes.aspx</a></li>
  </ul>
  
  <p>It seems like a bad driver is the culprit, so I'm going to reinstall Windows soon.</p>