diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp @@ -165,7 +165,13 @@ #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 @@ // 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()).