[all-commits] [llvm/llvm-project] 888951: Disable interception of sigaltstack on i386 macOS.
danliew via All-commits
all-commits at lists.llvm.org
Tue Jul 7 10:16:24 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 888951aaca583bcce85b42ea6166416db8f96fe0
https://github.com/llvm/llvm-project/commit/888951aaca583bcce85b42ea6166416db8f96fe0
Author: Dan Liew <dan at su-root.co.uk>
Date: 2020-07-07 (Tue, 07 Jul 2020)
Changed paths:
M compiler-rt/lib/sanitizer_common/sanitizer_platform.h
M compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
Log Message:
-----------
Disable interception of sigaltstack on i386 macOS.
Summary:
28c91219c7e introduced an interceptor for `sigaltstack`. It turns out this
broke `setjmp` on i386 macOS. This is because the implementation of `setjmp` on
i386 macOS is written in assembly and makes the assumption that the call to
`sigaltstack` does not clobber any registers. Presumably that assumption was
made because it's a system call. In particular `setjmp` assumes that before
and after the call that `%ecx` will contain a pointer the `jmp_buf`. The
current interceptor breaks this assumption because it's written in C++ and
`%ecx` is not a callee-saved register. This could be fixed by writing a
trampoline interceptor to the existing interceptor in assembly that
ensures all the registers are preserved. However, this is a lot of work
for very little gain. Instead this patch just disables the interceptor
on i386 macOS.
For other Darwin architectures it currently appears to be safe to intercept
`sigaltstack` using the current implementation because:
* `setjmp` for x86_64 saves the pointer `jmp_buf` to the stack before calling `sigaltstack`.
* `setjmp` for armv7/arm64/arm64_32/arm64e appears to not call `sigaltstack` at all.
This patch should unbreak (once they are re-enabled) the following
tests:
```
AddressSanitizer-Unit :: ./Asan-i386-calls-Test/AddressSanitizer.LongJmpTest
AddressSanitizer-Unit :: ./Asan-i386-calls-Test/AddressSanitizer.SigLongJmpTest
AddressSanitizer-Unit :: ./Asan-i386-inline-Test/AddressSanitizer.LongJmpTest
AddressSanitizer-Unit :: ./Asan-i386-inline-Test/AddressSanitizer.SigLongJmpTest
AddressSanitizer-i386-darwin :: TestCases/longjmp.cpp
```
This patch introduces a `SANITIZER_I386` macro for convenience.
rdar://problem/62141412
Reviewers: kubamracek, yln, eugenis
Subscribers: kristof.beyls, #sanitizers, llvm-commits
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D82691
Commit: 8a8d6e2b727112fafc52477acaf25affb62b6e65
https://github.com/llvm/llvm-project/commit/8a8d6e2b727112fafc52477acaf25affb62b6e65
Author: Dan Liew <dan at su-root.co.uk>
Date: 2020-07-07 (Tue, 07 Jul 2020)
Changed paths:
M compiler-rt/lib/asan/tests/asan_test.cpp
Log Message:
-----------
Revert "Temporarily disable the following failing tests on Darwin:"
This reverts commit f3a089506fdcc4a1d658697009572c93e00c4373.
888951aaca583bcce85b42ea6166416db8f96fe0 introduced a fix that
should make the disabled tests work again.
rdar://problem/62141412
Compare: https://github.com/llvm/llvm-project/compare/5e9b16b67f5b...8a8d6e2b7271
More information about the All-commits
mailing list