Skip to content

Commit c265d98

Browse files
committed
[libFuzzer] always install signal handler with SA_ONSTACK
SA_ONSTACK is required for certain runtimes that use small stacks, for instance the Go runtime. See golang/go#49075 SA_ONSTACK is a no-op unless someone also calls sigaltstack.
1 parent e3e7393 commit c265d98

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,14 @@ static void SetSigaction(int signum,
7878
}
7979

8080
struct sigaction new_sigact = {};
81-
// Address sanitizer needs SA_ONSTACK (causing the signal handler to run on a
82-
// dedicated stack) in order to be able to detect stack overflows; keep the
83-
// flag if it's set.
84-
new_sigact.sa_flags = SA_SIGINFO | (sigact.sa_flags & SA_ONSTACK);
81+
// SA_ONSTACK is required for certain runtimes that use small stacks, for
82+
// instance the Go runtime.
83+
// See https://github.com/golang/go/issues/49075
84+
// Address sanitizer also wants SA_ONSTACK, and the fuzzer and sanitizer
85+
// often run together.
86+
// SA_ONSTACK is a no-op unless someone also calls sigaltstack. That is left
87+
// up to code that needs it.
88+
new_sigact.sa_flags = SA_SIGINFO | SA_ONSTACK;
8589
new_sigact.sa_sigaction = callback;
8690
if (sigaction(signum, &new_sigact, nullptr)) {
8791
Printf("libFuzzer: sigaction failed with %d\n", errno);

0 commit comments

Comments
 (0)