This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] malloc: Perform full initialization before __malloc_check_init
- From: fweimer at redhat dot com (Florian Weimer)
- To: libc-alpha at sourceware dot org
- Date: Wed, 20 Sep 2017 14:27:18 +0200
- Subject: [PATCH] malloc: Perform full initialization before __malloc_check_init
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=fweimer at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 236CEC047B82
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);