Skip to content

Commit 407b2c6

Browse files
committed
[sanitizer-common] Provide warning if task_set_exc_guard_behavior errors
1 parent 47ea854 commit 407b2c6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,18 @@ static void DisableMmapExcGuardExceptions() {
960960
RTLD_DEFAULT, "task_set_exc_guard_behavior");
961961
if (set_behavior == nullptr) return;
962962
const task_exc_guard_behavior_t task_exc_guard_none = 0;
963-
set_behavior(mach_task_self(), task_exc_guard_none);
963+
kern_return_t res = set_behavior(mach_task_self(), task_exc_guard_none);
964+
if (res != KERN_SUCCESS) {
965+
Report(
966+
"WARN: AddressSanitizer: task_set_exc_guard_behavior returned %d (%s), "
967+
"mmap may fail unexpectedly.\n",
968+
res, mach_error_string(res));
969+
if (res == KERN_DENIED) {
970+
Report(
971+
"HINT: Check that task_set_exc_guard_behavior is allowed by "
972+
"sandbox.\n");
973+
}
974+
}
964975
}
965976

966977
static void VerifyInterceptorsWorking();

0 commit comments

Comments
 (0)