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

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Richard Biener from comment #2)
> Confirmed by code inspection, but it's for sure sth not new (but would be
> nice to fix before GCC 11.1).
> 
> I suggtest to simply move the initialization inside SetAlternateSignalStack.
> Sth like
> 
> diff --git a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp
> b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp
> index d29438cf9db..803712e268e 100644
> --- a/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp
> +++ b/libsanitizer/sanitizer_common/sanitizer_posix_libcdep.cpp
> @@ -165,7 +165,7 @@ bool SupportsColoredOutput(fd_t fd) {
>  
>  #if !SANITIZER_GO
>  // TODO(glider): different tools may require different altstack size.
> -static const uptr kAltStackSize = SIGSTKSZ * 4;  // SIGSTKSZ is not enough.
> +static const uptr kAltStackSize;
>  
>  void SetAlternateSignalStack() {
>    stack_t altstack, oldstack;
> @@ -176,6 +176,7 @@ void SetAlternateSignalStack() {
>    // 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()).
> +  kAltStackSize = SIGSTKSZ * 4;  // SIGSTKSZ is not enough.
>    void* base = MmapOrDie(kAltStackSize, __func__);
>    altstack.ss_sp = (char*) base;
>    altstack.ss_flags = 0;

We can initialize it with a constructor or .init_array.

Reply via email to