<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - LLDB keeps DLL loaded after FreeLibrary is called."
   href="https://bugs.llvm.org/show_bug.cgi?id=52017">52017</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLDB keeps DLL loaded after FreeLibrary is called.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>12.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>george.owen@savoch.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=25307" name="attach_25307" title="Test case">attachment 25307</a> <a href="attachment.cgi?id=25307&action=edit" title="Test case">[details]</a></span>
Test case

Repro:
 * Build a shared library DLL
 * Create an executable that does not link that DLL
 * Load a DLL in code using LoadLibrary
 * Unload the same DLL using FreeLibrary on the HMODULE obtained from the first
step
 * Observe that LLDB does not release its lock on the DLL file, until LLDB is
closed.

LLDB keeps DLL loaded (and therefore the file locked) even after the
FreeLibrary is called. This means that the DLL, and PDB, both remain locked and
unable to be modified, even after they are no longer required by LLDB.

This can be observed by building the attached test case and running it through
LLDB. Once the program is either breakpointed or paused after the FreeLibrary
call, you can either attempt to delete the files and observe they cannot be
deleted, or use a program such as Process Explorer
(<a href="https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer">https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer</a>) to
see the processes that keep a handle to the file. This is only released when
LLDB is closed.

Debugging the same test case with Visual Studio 2019 (Version 16.9.4) shows
that Visual Studio does not keep the DLL or PDB locked after FreeLibrary is
called.</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>