[LLVMbugs] [Bug 21682] TrieEdge leak in MachONormalizedFileBinaryWriter.cpp

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Dec 2 02:17:08 PST 2014


Jean-Daniel Dupas <devlists at shadowlab.org> changed:

           What    |Removed                     |Added
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #3 from Jean-Daniel Dupas <devlists at shadowlab.org> ---
When I said using a list, I didn't mean a std::list. std::list, like any other
STL structure, will allocate memory and require there destructor to be called
to release it. While TrieNode are allocated by the bumpPtrAllocator, the
TrieNode destructor is never called, and neither is the _children member

Moreover, while your patch allocate the TrieEdge using the allocator, it is
then dereferenced and it's content is copied (move) on the list storage, which
is worse than the previous implementation as the freshly allocated Edge is
leaked immediately (the allocated memory will be released when the allocator is
destroyed, but it means the allocation is useless in the first place. An
emplace_back() will be more efficient and have the same effect).

Even using a list<TrieEdge *> will not solve the issue, as the memory allocated
by the list to store the pointer will leaks.

What I though was more something like the solution in the patch from my
previous comment. Note that this is just a proof of concept (ignore whitespace
convention and may probably be improved).

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/20141202/075e5b50/attachment.html>

More information about the llvm-bugs mailing list