This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] malloc: Perform full initialization before __malloc_check_init


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]