[all-commits] [llvm/llvm-project] cc08a2: Sanitizer built against glibc 2.34 doesn't work

Tom Stellard via All-commits all-commits at lists.llvm.org
Mon Jun 21 21:43:59 PDT 2021


  Branch: refs/heads/release/12.x
  Home:   https://github.com/llvm/llvm-project
  Commit: cc08a27d2ecc1458a8871c989add0b49afc24f12
      https://github.com/llvm/llvm-project/commit/cc08a27d2ecc1458a8871c989add0b49afc24f12
  Author: Vitaly Buka <vitalybuka at google.com>
  Date:   2021-06-22 (Tue, 22 Jun 2021)

  Changed paths:
    M compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp

  Log Message:
  -----------
  Sanitizer built against glibc 2.34 doesn't work

As mentioned in https://gcc.gnu.org/PR100114 , glibc starting with the
https://sourceware.org/git/?p=glibc.git;a=commit;h=6c57d320484988e87e446e2e60ce42816bf51d53
change doesn't define SIGSTKSZ and MINSIGSTKSZ macros to constants, but to sysconf function call.
sanitizer_posix_libcdep.cpp has
static const uptr kAltStackSize = SIGSTKSZ * 4;  // SIGSTKSZ is not enough.
which is generally fine, just means that when SIGSTKSZ is not a compile time constant will be initialized later.
The problem is that kAltStackSize is used in SetAlternateSignalStack which is called very early, from .preinit_array
initialization, i.e. far before file scope variables are constructed, which means it is not initialized and
mmapping 0 will fail:
==145==ERROR: AddressSanitizer failed to allocate 0x0 (0) bytes of SetAlternateSignalStack (error code: 22)

Here is one possible fix, another one could be to make kAltStackSize a preprocessor macro if _SG_SIGSTKSZ is defined
(but perhaps with having an automatic const variable initialized to it so that sysconf isn't at least called twice
during SetAlternateSignalStack.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D100645

(cherry picked from commit 82150606fb11d28813ae6da1101f5bda638165fe)


  Commit: 385a6f37fefbeb1397f1c3733f328bb2b0403e2b
      https://github.com/llvm/llvm-project/commit/385a6f37fefbeb1397f1c3733f328bb2b0403e2b
  Author: serge-sans-paille <sguelton at redhat.com>
  Date:   2021-06-22 (Tue, 22 Jun 2021)

  Changed paths:
    M compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp

  Log Message:
  -----------
  Prevent generation of dependency on _cxa_guard for static initialization

This fixes an issue introduced by https://reviews.llvm.org/D70662

Function-scope static initialization are guarded in C++, so we should probably
not use it because it introduces a dependency on __cxa_guard* symbols.
In the context of clang, libasan is linked statically, and it currently needs to
the odd situation where compiling C code with clang and asan requires -lstdc++

Differential Revision: https://reviews.llvm.org/D102475

(cherry picked from commit 414482751452e54710f16bae58458c66298aaf69)


Compare: https://github.com/llvm/llvm-project/compare/051126fe6ffe...385a6f37fefb


More information about the All-commits mailing list