https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100114

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
const vars in C++ can't be uninitialized nor modified.
And initializing those in constructor or .init_array is too late, the problem
is
that the function is called from .preinit_array handler, so before anything is
constructed.

I'd suggest
--- libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp.jj       
2020-11-13 19:00:46.909618582 +0100
+++ libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp   2021-04-16
15:19:56.211942944 +0200
@@ -165,7 +165,13 @@ bool SupportsColoredOutput(fd_t fd) {

 #if !SANITIZER_GO
 // TODO(glider): different tools may require different altstack size.
+#if SANITIZER_LINUX && defined(_SC_SIGSTKSZ)
+// In glibc 2.34 and later SIGSTKSZ is no longer a compile time constant,
+// but sysconf (_SC_SIGSTKSZ) call.
+static uptr kAltStackSize;
+#else
 static const uptr kAltStackSize = SIGSTKSZ * 4;  // SIGSTKSZ is not enough.
+#endif

 void SetAlternateSignalStack() {
   stack_t altstack, oldstack;
@@ -173,6 +179,9 @@ void SetAlternateSignalStack() {
   // If the alternate stack is already in place, do nothing.
   // Android always sets an alternate stack, but it's too small for us.
   if (!SANITIZER_ANDROID && !(oldstack.ss_flags & SS_DISABLE)) return;
+#if SANITIZER_LINUX && defined(_SC_SIGSTKSZ)
+  if (!kAltStackSize) kAltStackSize = SIGSTKSZ * 4;
+#endif
   // TODO(glider): the mapped stack should have the MAP_STACK flag in the
   // future. It is not required by man 2 sigaltstack now (they're using
   // malloc()).

Reply via email to