[all-commits] [llvm/llvm-project] 821506: Sanitizer built against glibc 2.34 doesn't work
Vitaly Buka via All-commits
all-commits at lists.llvm.org
Fri Apr 16 11:21:33 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 82150606fb11d28813ae6da1101f5bda638165fe
https://github.com/llvm/llvm-project/commit/82150606fb11d28813ae6da1101f5bda638165fe
Author: Vitaly Buka <vitalybuka at google.com>
Date: 2021-04-16 (Fri, 16 Apr 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
More information about the All-commits
mailing list