<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:devlists@shadowlab.org" title="Jean-Daniel Dupas <devlists@shadowlab.org>"> <span class="fn">Jean-Daniel Dupas</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED --- - TrieEdge leak in MachONormalizedFileBinaryWriter.cpp"
   href="http://llvm.org/bugs/show_bug.cgi?id=21682">bug 21682</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>RESOLVED
           </td>
           <td>REOPENED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>FIXED
           </td>
           <td>---
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED --- - TrieEdge leak in MachONormalizedFileBinaryWriter.cpp"
   href="http://llvm.org/bugs/show_bug.cgi?id=21682#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_REOPENED "
   title="REOPENED --- - TrieEdge leak in MachONormalizedFileBinaryWriter.cpp"
   href="http://llvm.org/bugs/show_bug.cgi?id=21682">bug 21682</a>
              from <span class="vcard"><a class="email" href="mailto:devlists@shadowlab.org" title="Jean-Daniel Dupas <devlists@shadowlab.org>"> <span class="fn">Jean-Daniel Dupas</span></a>
</span></b>
        <pre>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
destructor.

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).</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>