[compiler-rt] 7e946d0 - [compiler-rt][Darwin] Disable EXC_GUARD exceptions
Julian Lettner via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 29 11:22:48 PDT 2020
Author: Julian Lettner
Date: 2020-07-29T11:21:25-07:00
New Revision: 7e946d0c8289ff8cafcae88595b805ec511db6b4
URL: https://github.com/llvm/llvm-project/commit/7e946d0c8289ff8cafcae88595b805ec511db6b4
DIFF: https://github.com/llvm/llvm-project/commit/7e946d0c8289ff8cafcae88595b805ec511db6b4.diff
LOG: [compiler-rt][Darwin] Disable EXC_GUARD exceptions
ASan/TSan use mmap in a way that creates “deallocation gaps” which
triggers EXC_GUARD exceptions on macOS 10.15+ (XNU 19.0+). Let's
suppress those.
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index f96f18713197..5b06fee62c13 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -831,6 +831,19 @@ void SignalContext::InitPcSpBp() {
GetPcSpBp(context, &pc, &sp, &bp);
}
+// ASan/TSan use mmap in a way that creates “deallocation gaps” which triggers
+// EXC_GUARD exceptions on macOS 10.15+ (XNU 19.0+).
+static void DisableMmapExcGuardExceptions() {
+ using task_exc_guard_behavior_t = uint32_t;
+ using task_set_exc_guard_behavior_t =
+ kern_return_t(task_t task, task_exc_guard_behavior_t behavior);
+ auto *set_behavior = (task_set_exc_guard_behavior_t *)dlsym(
+ RTLD_DEFAULT, "task_set_exc_guard_behavior");
+ if (set_behavior == nullptr) return;
+ const task_exc_guard_behavior_t task_exc_guard_none = 0;
+ set_behavior(mach_task_self(), task_exc_guard_none);
+}
+
void InitializePlatformEarly() {
// Only use xnu_fast_mmap when on x86_64 and the kernel supports it.
use_xnu_fast_mmap =
@@ -839,6 +852,8 @@ void InitializePlatformEarly() {
#else
false;
#endif
+ if (GetDarwinKernelVersion() >= DarwinKernelVersion(19, 0))
+ DisableMmapExcGuardExceptions();
}
#if !SANITIZER_GO
More information about the llvm-commits
mailing list