This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] malloc: Perform full initialization before __malloc_check_init
- From: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- To: Florian Weimer <fweimer at redhat dot com>, "dj at redhat dot com" <dj at redhat dot com>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Cc: nd <nd at arm dot com>
- Date: Thu, 21 Sep 2017 18:15:07 +0000
- Subject: Re: [PATCH] malloc: Perform full initialization before __malloc_check_init
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco dot Dijkstra at arm dot com;
- Nodisclaimer: True
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Florian Weimer wrote:
Well it looks like the malloc initialization is insane. It sets default hooks for
malloc/realloc/etc which call ptmalloc_init, which is completely unguarded
from multi-threaded execution... Then it implicitly relies on have_fastchunks
being true (from zero-initialization of main_arena by inverting the meaning of
the flag), which should eventually result in a call to malloc_consolidate, which
assuming max_fast hasn't yet been set, finally calls malloc_init_state...
+ {
+ /* Perform full initialization. */
+ malloc_consolidate (&main_arena);
+ __malloc_check_init ();
+ }
That's an improvement but ptmalloc_init should call malloc_init_state (&main_arena)
in all cases. The check in malloc_consolidate should then be removed (no idea why
anyone would want to delay initialization to that point...). Interestingly malloc_init_state
is called for other arenas...
Wilco