[LLVMbugs] [Bug 21681] New: Memory leak in FileArchive::find()

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Nov 27 04:11:32 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=21681

            Bug ID: 21681
           Summary: Memory leak in FileArchive::find()
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: devlists at shadowlab.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

In Resolver::handleArchiveFile(), there is a call to archiveFile->find() that
may end up calling FileArchive::find().

FileArchive::find() create a new File (enclosed in a unique_ptr) and then
return it by releasing ownership (comment before the return statement: "// give
up the pointer so that this object no longer manages it").

The problem is that find() is a virtual method and may or may not returns a
owned pointer. The caller (Resolver) has no way to know if it should delete the
pointer after use. In fact, other implementation of ArchiveLibraryFile returns
a owned-pointer that must not be freed by the find() caller.

I think a solution could be to add a FileVectorT to FileArchive to keep track
of all returned files, and delete them when the FileArchive is destroyed.

Anyway, we should clarify the ownership of the pointer returned by the
ArchiveLibraryFile::find() virtual method and make sure all subclasses conform
to that contract.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141127/5cb58fcc/attachment.html>


More information about the llvm-bugs mailing list