This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] [v6] malloc: Consistently apply trim_threshold to all heaps [BZ #17195]
- From: Mel Gorman <mgorman at suse dot de>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: libc-alpha at sourceware dot org, Julian Taylor <jtaylor dot debian at googlemail dot com>, Carlos O'Donell <carlos at redhat dot com>
- Date: Tue, 24 Feb 2015 10:47:12 +0000
- Subject: Re: [PATCH] [v6] malloc: Consistently apply trim_threshold to all heaps [BZ #17195]
- Authentication-results: sourceware.org; auth=none
- References: <20150220132747 dot GV3087 at suse dot de> <20150224070118 dot GE23807 at spoyarek dot pnq dot redhat dot com>
On Tue, Feb 24, 2015 at 12:31:18PM +0530, Siddhesh Poyarekar wrote:
> On Fri, Feb 20, 2015 at 01:27:47PM +0000, Mel Gorman wrote:
> > 2015-02-10 Mel Gorman <mgorman@suse.de>
> >
> > [BZ #17195]
> > * malloc/arena.c (free): Apply trim threshold to per-thread heaps
> > as well as the main arena.
> > ---
> > malloc/arena.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/malloc/arena.c b/malloc/arena.c
> > index 886defb074a2..fec339819309 100644
> > --- a/malloc/arena.c
> > +++ b/malloc/arena.c
> > @@ -696,7 +696,7 @@ heap_trim (heap_info *heap, size_t pad)
> > }
> > top_size = chunksize (top_chunk);
> > extra = (top_size - pad - MINSIZE - 1) & ~(pagesz - 1);
> > - if (extra < (long) pagesz)
> > + if ((unsigned long) extra < mp_.trim_threshold)
> > return 0;
> >
> > /* Try to shrink. */
>
> Looks like this exposes some kind of a race. I ran the testsuite with
> this patch and intl/tst-gettext4 and intl/tst-gettext5 fail with a
> segfault. From a quick peek it looks like a malloc trying to tinker
> with the part of an arena that has not yet been allocated, i.e. does
> not have any permissions. Can you please look into it? I can't push
> this till that problem is solved.
>
Ok, I'll start taking a look. I have yet to properly investigate but I
do think this is an existing problem that the patch makes worse because
I find this
# This is a test run using the glibc installed on the system
mel@stampy:~/git-public/glibc/obj-baseline > ./intl/tst-gettext4
beauty
thread 1 call 1 returned: beauty
beauty
thread 2 call 1 returned: beauty
beauty
thread 1 call 2 returned: beauty
beauty
thread 2 call 2 returned: beauty
# This is a test run using glibc 2.21
mel@stampy:~/git-public/glibc/obj-baseline > ./testrun.sh ./intl/tst-gettext4
Schï¿œnheit
beautᅵ
Schï¿œnheit
beautᅵ
# This is a test run using glibc 2.21 + the patch
mel@stampy:~/git-public/glibc/obj-madvise-reduce-v6r1 > ./testrun.sh ./intl/tst-gettext4
Segmentation fault (core dumped)
glibc 2.21 does not segfault but the output from glibc 2.21 looks pretty
screwed up relative to glibc 2.19 that is installed on the system.
--
Mel Gorman
SUSE Labs