[lldb-dev] [Bug 52017] New: LLDB keeps DLL loaded after FreeLibrary is called.

via lldb-dev lldb-dev at lists.llvm.org
Wed Sep 29 15:32:13 PDT 2021


            Bug ID: 52017
           Summary: LLDB keeps DLL loaded after FreeLibrary is called.
           Product: lldb
           Version: 12.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: lldb-dev at lists.llvm.org
          Reporter: george.owen at savoch.net
                CC: jdevlieghere at apple.com, llvm-bugs at lists.llvm.org

Created attachment 25307
  --> https://bugs.llvm.org/attachment.cgi?id=25307&action=edit
Test case

 * 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
 * Observe that LLDB does not release its lock on the DLL file, until LLDB is

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
(https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer) 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

You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20210929/9e220e6a/attachment.html>

More information about the lldb-dev mailing list