This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] malloc: Prevent arena free_list from turning cyclic [BZ #19048]
- From: Paulo CÃsar Pereira de Andrade <paulo dot cesar dot pereira dot de dot andrade at gmail dot com>
- To: Siddhesh Poyarekar <sid at reserved-bit dot com>
- Cc: Florian Weimer <fweimer at redhat dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Fri, 9 Oct 2015 18:29:10 -0300
- Subject: Re: [PATCH] malloc: Prevent arena free_list from turning cyclic [BZ #19048]
- Authentication-results: sourceware.org; auth=none
- References: <5617E843 dot 3060504 at redhat dot com> <5618075F dot 105 at reserved-bit dot com> <561807D9 dot 2080604 at reserved-bit dot com>
2015-10-09 15:30 GMT-03:00 Siddhesh Poyarekar <sid@reserved-bit.com>:
> On Friday 09 October 2015 11:58 PM, Siddhesh Poyarekar wrote:
>
>>> +static void
>>> +deattach_arena (mstate replaced_arena)
>>
>> Call it detach_arena if you want to keep it a separate function.
>
> To be clear, it seems to me that consolidating to arena_get2 would mean
> that detach_arena is called in only one place and hence may not deserve
> to be a separate function.
My first idea was to create a reference counter, and only put
arenas in the free_list if the reference counter goes down to zero.
If I understand correctly, adding a reference counter, but having
more threads then arenas, will cause it to cycle in the next pointer,
until there are less threads than arenas, in which case, the
next_free pointer would become close to useless, as well as the
reference counter, because they would seldomly be used.
I confess I do not correctly understand what was the original
idea of the free_list pointer, but after thinking about a reference
counter, I preferred the two proposed patches, that are localized.
Either add the arena in the tail of the free_list, or in the head as
the last proposed one, as it would have the same behavior of
current glibc, sans correcting the free_list corruption.
> Siddhesh
Thanks,
Paulo