From 86229ccd49cdbd318b18fc7d10cc05cc662247fb Mon Sep 17 00:00:00 2001 From: Chris Cotter Date: Wed, 31 Jul 2024 23:10:04 -0400 Subject: [PATCH] Reduce the MSAN TlS requirements to workaround glibc limitation Workaround issue where older glibc cannot allocate large TLS blocks after the program has started running ("cannot allocate memory in static TLS block"). ref: https://github.com/microsoft/LightGBM/issues/6509 https://bugzilla.redhat.com/show_bug.cgi?id=1722181 --- compiler-rt/lib/msan/msan.h | 4 ++-- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler-rt/lib/msan/msan.h b/compiler-rt/lib/msan/msan.h index 7fb58be67a02cd..e247921e696050 100644 --- a/compiler-rt/lib/msan/msan.h +++ b/compiler-rt/lib/msan/msan.h @@ -254,8 +254,8 @@ addr_is_type(uptr addr, int mapping_types) { #define MEM_IS_ORIGIN(mem) addr_is_type((uptr)(mem), MappingDesc::ORIGIN) // These constants must be kept in sync with the ones in MemorySanitizer.cpp. -const int kMsanParamTlsSize = 800; -const int kMsanRetvalTlsSize = 800; +const int kMsanParamTlsSize = 200; +const int kMsanRetvalTlsSize = 200; namespace __msan { extern int msan_inited; diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index c979e81ac1a3fe..e67c4ae2019175 100644 --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -224,8 +224,8 @@ static const Align kMinOriginAlignment = Align(4); static const Align kShadowTLSAlignment = Align(8); // These constants must be kept in sync with the ones in msan.h. -static const unsigned kParamTLSSize = 800; -static const unsigned kRetvalTLSSize = 800; +static const unsigned kParamTLSSize = 200; +static const unsigned kRetvalTLSSize = 200; // Accesses sizes are powers of two: 1, 2, 4, 8. static const size_t kNumberOfAccessSizes = 4;