[PATCH] malloc: Perform full initialization before __malloc_check_init
Florian Weimer
fweimer@redhat.com
Wed Sep 20 12:27:00 GMT 2017
Previously, initialization was implicitly performed by mallopt,
but commit ac3ed168d0c0b2b702319ac0db72c9b475a8c72e (malloc:
Remove check_action variable) removed the mallopt call.
2017-09-20 Florian Weimer <fweimer@redhat.com>
* malloc/arena.c [!HAVE_TUNABLES] (ptmalloc_init): Call
malloc_consolidate before __malloc_check_init.
diff --git a/malloc/arena.c b/malloc/arena.c
index 9e5a62d260..eabff741ee 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -322,14 +322,14 @@ ptmalloc_init (void)
TUNABLE_GET (mmap_max, int32_t, TUNABLE_CALLBACK (set_mmaps_max));
TUNABLE_GET (arena_max, size_t, TUNABLE_CALLBACK (set_arena_max));
TUNABLE_GET (arena_test, size_t, TUNABLE_CALLBACK (set_arena_test));
-#if USE_TCACHE
+# if USE_TCACHE
TUNABLE_GET (tcache_max, size_t, TUNABLE_CALLBACK (set_tcache_max));
TUNABLE_GET (tcache_count, size_t, TUNABLE_CALLBACK (set_tcache_count));
TUNABLE_GET (tcache_unsorted_limit, size_t,
TUNABLE_CALLBACK (set_tcache_unsorted_limit));
-#endif
+# endif
__libc_lock_unlock (main_arena.mutex);
-#else
+#else /* !HAVE_TUNABLES */
const char *s = NULL;
if (__glibc_likely (_environ != NULL))
{
@@ -393,8 +393,12 @@ ptmalloc_init (void)
}
}
if (s && s[0] != '\0' && s[0] != '0')
- __malloc_check_init ();
-#endif
+ {
+ /* Perform full initialization. */
+ malloc_consolidate (&main_arena);
+ __malloc_check_init ();
+ }
+#endif /* !HAVE_TUNABLES */
#if HAVE_MALLOC_INIT_HOOK
void (*hook) (void) = atomic_forced_read (__malloc_initialize_hook);
More information about the Libc-alpha
mailing list