Fix hashtable memory leak

François Dumont frs.dumont@gmail.com
Sat Nov 24 21:58:00 GMT 2018


Tests have shown a regression. I was building the _ReuseOrAllocNode 
instance too early, node ownership was transfered but was still owned by 
_Hashtable instance.

This new version pass all tests.

Ok to commit ?

François



On 11/19/18 10:23 PM, François Dumont wrote:
> There a memory leak when move assigning between 2 instances with 
> different bucket count and non-propagating and unequal allocator 
> instances (see new test03).
>
> I reduced code duplication to fix the issue as 1 of the 2 
> implementations was fine.
>
>     * include/bits/hashtable.h (_Hashtable<>::_M_replicate): New.
>     (_Hashtable<>::operator=(const _Hashtable&)): Use latter.
>     (_Hashtable<>::_M_move_assign(_Hashtable&&, false_type)): Likewise.
>     * testsuite/23_containers/unordered_set/allocator/move_assign.cc
>     (test03): New.
>
> I still need to run all tests but new move_assign.cc works fine.
>
> Ok to commit once fully tested ?
>
> François
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: hashtable_mem_leak.patch
Type: text/x-patch
Size: 6598 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20181124/d7d99d70/attachment.bin>


More information about the Gcc-patches mailing list