malloc: Use initial-exec TLS in libmemusage

Message ID
State New
Series malloc: Use initial-exec TLS in libmemusage |


Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
redhat-pt-bot/TryBot-32bit success Build for i686
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Test passed

Commit Message

Florian Weimer July 9, 2024, 7:34 a.m. UTC
  The start_sp variable is accessed from a signal handler, and
global-dynamic TLS is not necessarily async-signal-safe in the
current implementation.  This change also aligns libmemusage with
the recommendation to use initial-exec TLS in malloc

 malloc/memusage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


diff --git a/malloc/memusage.c b/malloc/memusage.c
index e8ae80dc74..46c8434ae1 100644
--- a/malloc/memusage.c
+++ b/malloc/memusage.c
@@ -86,7 +86,7 @@  static _Atomic unsigned long int inplace_mremap;
 static _Atomic unsigned long int decreasing_mremap;
 static _Atomic size_t current_heap;
 static _Atomic size_t peak_use[3];
-static __thread uintptr_t start_sp;
+static __thread uintptr_t start_sp attribute_tls_model_ie;
 /* A few macros to make the source more readable.  */
 #define peak_heap       peak_use[0]