<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Dynamic loading/unloading of opengl32.dll results in a deadlock"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=76252#c6">Comment # 6</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Dynamic loading/unloading of opengl32.dll results in a deadlock"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=76252">bug 76252</a>
              from <span class="vcard"><a class="email" href="mailto:jfonseca@vmware.com" title="José Fonseca <jfonseca@vmware.com>"> <span class="fn">José Fonseca</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=76252#c5">comment #5</a>)
<span class="quote">> Can you explain the problem more? Thread 2's stack trace seems like it is
> waiting on ... something, but it isn't clear what or why. </span >

<span class="quote">> Is this the NT
> subsystem pausing it during thread unload? </span >

I can only guess, but yes, this is some internal DllMain-related global lock.

<span class="quote">> If so, why does this cause a
> problem, i.e. why does lp_rast_destroy() hang instead of proceed if there is
> only one thread that is accessing the lock?</span >

I believe this lock is also held by the main thread.  From what I gather the
dead lock is as follows:

 - the main thread held a lock before entering DllMain(DLL_PROCESS_DETACH), and
is now wait for the llvmpipe worker thread to finish

 - the llvmpipe worker threads are trying to get the lock so it calls
DllMain(DLL_THREAD_DETACH) for all DLLs, so it can never finish

See also:

 -  <a href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;142243">http://support.microsoft.com/default.aspx?scid=kb;EN-US;142243</a>

  - <a href="http://msdn.microsoft.com/en-us/library/ms682583%28VS.85%29.aspx">http://msdn.microsoft.com/en-us/library/ms682583%28VS.85%29.aspx</a>

    "Because DLL notifications are serialized, entry-point functions should not
attempt to communicate with other threads or processes. Deadlocks may occur as
a result."

  -
<a href="http://stackoverflow.com/questions/2603583/boost-thread-hanging-on-endthreadex">http://stackoverflow.com/questions/2603583/boost-thread-hanging-on-endthreadex</a> 
  - <a href="http://stackoverflow.com/questions/353038/endthreadex0-hangs">http://stackoverflow.com/questions/353038/endthreadex0-hangs</a>
  -
<a href="http://stackoverflow.com/questions/10441048/exit-thread-upon-deleting-static-object-during-unload-dll-causes-deadlock">http://stackoverflow.com/questions/10441048/exit-thread-upon-deleting-static-object-during-unload-dll-causes-deadlock</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>