]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
malloc: Fix malloc init order
authorWilco Dijkstra <wilco.dijkstra@arm.com>
Tue, 27 May 2025 13:32:45 +0000 (13:32 +0000)
committerWilco Dijkstra <wilco.dijkstra@arm.com>
Tue, 27 May 2025 15:25:30 +0000 (15:25 +0000)
__ptmalloc_init was called too early in __libc_early_init: it uses
__libc_initial which is not set yet.  Fix this by moving initialization
to the end of __libc_early_init.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
elf/libc_early_init.c

index 24b99d82fe28f4c324800dbc665fb0e9c702c228..4da170a7ca3a9a6c6ec41c983fc9fc0e33e63be8 100644 (file)
@@ -33,9 +33,6 @@ _Bool __libc_initial;
 void
 __libc_early_init (_Bool initial)
 {
-  /* Initialize system malloc.  */
-  call_function_static_weak (__ptmalloc_init);
-
   /* Initialize ctype data.  */
   __ctype_init ();
 
@@ -53,4 +50,7 @@ __libc_early_init (_Bool initial)
 #if ENABLE_ELISION_SUPPORT
   __lll_elision_init ();
 #endif
+
+  /* Initialize system malloc (needs __libc_initial to be set).  */
+  call_function_static_weak (__ptmalloc_init);
 }