forked from OSchip/llvm-project
[libFuzzer] Don't replace custom signal handlers.
Summary: This allows to keep handlers installed by sanitizers. In other cases third-party code can replace handlers after libFuzzer initialization anyway. Reviewers: kcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33522 llvm-svn: 303828
This commit is contained in:
parent
a1c532784d
commit
bf40f1b6dd
|
@ -47,8 +47,21 @@ static void FileSizeExceedHandler(int, siginfo_t *, void *) {
|
|||
|
||||
static void SetSigaction(int signum,
|
||||
void (*callback)(int, siginfo_t *, void *)) {
|
||||
struct sigaction sigact;
|
||||
memset(&sigact, 0, sizeof(sigact));
|
||||
struct sigaction sigact = {};
|
||||
if (sigaction(signum, nullptr, &sigact)) {
|
||||
Printf("libFuzzer: sigaction failed with %d\n", errno);
|
||||
exit(1);
|
||||
}
|
||||
if (sigact.sa_flags & SA_SIGINFO) {
|
||||
if (sigact.sa_sigaction)
|
||||
return;
|
||||
} else {
|
||||
if (sigact.sa_handler != SIG_DFL && sigact.sa_handler != SIG_IGN &&
|
||||
sigact.sa_handler != SIG_ERR)
|
||||
return;
|
||||
}
|
||||
|
||||
sigact = {};
|
||||
sigact.sa_sigaction = callback;
|
||||
if (sigaction(signum, &sigact, 0)) {
|
||||
Printf("libFuzzer: sigaction failed with %d\n", errno);
|
||||
|
|
|
@ -3,3 +3,5 @@ LIBFUZZER_OWN_SEGV_HANDLER: == ERROR: libFuzzer: deadly signal
|
|||
LIBFUZZER_OWN_SEGV_HANDLER: SUMMARY: libFuzzer: deadly signal
|
||||
LIBFUZZER_OWN_SEGV_HANDLER: Test unit written to ./crash-
|
||||
|
||||
RUN: env ASAN_OPTIONS=handle_segv=1 not LLVMFuzzer-NullDerefTest 2>&1 | FileCheck %s --check-prefix=LIBFUZZER_ASAN_SEGV_HANDLER
|
||||
LIBFUZZER_ASAN_SEGV_HANDLER: ERROR: AddressSanitizer: {{SEGV|access-violation}} on unknown address
|
||||
|
|
Loading…
Reference in New Issue