[compiler-rt] aee4f2b - [libFuzzer] always install signal handler with SA_ONSTACK (#147422)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 9 11:45:45 PDT 2025
Author: Keith Randall
Date: 2025-08-09T11:45:41-07:00
New Revision: aee4f2baccdbc018d0ac60eaa4e2a0a5f30bcdf5
URL: https://github.com/llvm/llvm-project/commit/aee4f2baccdbc018d0ac60eaa4e2a0a5f30bcdf5
DIFF: https://github.com/llvm/llvm-project/commit/aee4f2baccdbc018d0ac60eaa4e2a0a5f30bcdf5.diff
LOG: [libFuzzer] always install signal handler with SA_ONSTACK (#147422)
SA_ONSTACK is required for certain runtimes that use small stacks, for
instance the Go runtime.
See https://github.com/golang/go/issues/49075
SA_ONSTACK is a no-op unless someone also calls sigaltstack.
Added:
Modified:
compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
index ae22ecf108420..b1bb1387876e0 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
@@ -78,10 +78,14 @@ static void SetSigaction(int signum,
}
struct sigaction new_sigact = {};
- // Address sanitizer needs SA_ONSTACK (causing the signal handler to run on a
- // dedicated stack) in order to be able to detect stack overflows; keep the
- // flag if it's set.
- new_sigact.sa_flags = SA_SIGINFO | (sigact.sa_flags & SA_ONSTACK);
+ // SA_ONSTACK is required for certain runtimes that use small stacks, for
+ // instance the Go runtime.
+ // See https://github.com/golang/go/issues/49075
+ // Address sanitizer also wants SA_ONSTACK, and the fuzzer and sanitizer
+ // often run together.
+ // SA_ONSTACK is a no-op unless someone also calls sigaltstack. That is left
+ // up to code that needs it.
+ new_sigact.sa_flags = SA_SIGINFO | SA_ONSTACK;
new_sigact.sa_sigaction = callback;
if (sigaction(signum, &new_sigact, nullptr)) {
Printf("libFuzzer: sigaction failed with %d\n", errno);
More information about the llvm-commits
mailing list