From: Arran Cudbard-Bell Date: Sat, 10 Dec 2022 15:22:15 +0000 (-0600) Subject: Increase timeout for fuzzers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a4e942c583dc2a72c6324848a8defcf92bdfcfd;p=thirdparty%2Ffreeradius-server.git Increase timeout for fuzzers Some tweaks to try and get backtraces on timeout --- diff --git a/Make.inc.in b/Make.inc.in index 477ae3fcdba..11d1dcb01ff 100644 --- a/Make.inc.in +++ b/Make.inc.in @@ -204,12 +204,13 @@ ANALYZE.c := @clang_path@ # # Have wrappers for the test tools, so that they run. # -# We have a hardcoded maximum execution time of 30 seconds -# If your test takes > 30 seconds to run, you're doing +# We have a hardcoded maximum execution time of 300 seconds +# If your test takes > 300 seconds to run, you're doing # something wrong. # -TEST_BIN_DIR = ./$(BUILD_DIR)/bin/local -TEST_BIN = $(JLIBTOOL) $(if ${VERBOSE},--debug,--silent) --timeout=30 --mode=execute $(TEST_BIN_DIR) +TEST_BIN_DIR = ./$(BUILD_DIR)/bin/local +TEST_BIN = $(JLIBTOOL) $(if ${VERBOSE},--debug,--silent) --timeout=300 --mode=execute $(TEST_BIN_DIR) +TEST_BIN_NO_TIMEOUT = $(JLIBTOOL) $(if ${VERBOSE},--debug,--silent) --mode=execute $(TEST_BIN_DIR) # # For creating documentation via doc/all.mk diff --git a/scripts/jlibtool.c b/scripts/jlibtool.c index faf5ca3b81e..0808592c9d1 100644 --- a/scripts/jlibtool.c +++ b/scripts/jlibtool.c @@ -958,11 +958,10 @@ static int external_spawn(command_t *cmd, __attribute__((unused)) char const *fi */ if (timeout) { NOTICE("exec timeout\n"); - kill(spawn_pid, SIGKILL); + kill(spawn_pid, SIGALRM); waitpid(spawn_pid, &status, 0); /* Cleanup child state */ timeout = false; /* Reset */ - return 128 + SIGALRM; /* Allow the caller to figure out what happened */ } /* diff --git a/src/bin/fuzzer.mk b/src/bin/fuzzer.mk index 1c916347607..5f927cbc7b7 100644 --- a/src/bin/fuzzer.mk +++ b/src/bin/fuzzer.mk @@ -64,7 +64,7 @@ $(TEST_BIN_DIR)/fuzzer_$(PROTOCOL): $(BUILD_DIR)/lib/local/libfreeradius-$(PROTO # increase the size of the corpus by several times. # fuzzer.$(PROTOCOL): $(TEST_BIN_DIR)/fuzzer_$(PROTOCOL) | src/tests/fuzzer-corpus/$(PROTOCOL) - ${Q}$(TEST_BIN)/fuzzer_$(PROTOCOL) \ + ${Q}$(TEST_BIN_NO_TIMEOUT)/fuzzer_$(PROTOCOL) \ -artifact_prefix="$(FUZZER_ARTIFACTS)/$(PROTOCOL)/" \ -max_len=512 $(FUZZER_ARGUMENTS) \ -D share/dictionary \ @@ -76,7 +76,7 @@ fuzzer.$(PROTOCOL): $(TEST_BIN_DIR)/fuzzer_$(PROTOCOL) | src/tests/fuzzer-corpus ifeq "$(CI)" "" test.fuzzer.$(PROTOCOL): $(TEST_BIN_DIR)/fuzzer_$(PROTOCOL) | src/tests/fuzzer-corpus/$(PROTOCOL) @echo TEST-FUZZER $(PROTOCOL) for $(FUZZER_TIMEOUT)s - ${Q}$(TEST_BIN)/fuzzer_$(PROTOCOL) \ + ${Q}$(TEST_BIN_NO_TIMEOUT)/fuzzer_$(PROTOCOL) \ -artifact_prefix="$(FUZZER_ARTIFACTS)/$(PROTOCOL)/" \ -max_len=512 $(FUZZER_ARGUMENTS) \ -max_total_time=$(FUZZER_TIMEOUT) \ @@ -86,7 +86,7 @@ else test.fuzzer.$(PROTOCOL): $(TEST_BIN_DIR)/fuzzer_$(PROTOCOL) | src/tests/fuzzer-corpus/$(PROTOCOL) @echo TEST-FUZZER $(PROTOCOL) for $(FUZZER_TIMEOUT)s @mkdir -p $(BUILD_DIR)/fuzzer - ${Q}if ! $(TEST_BIN)/fuzzer_$(PROTOCOL) \ + ${Q}if ! $(TEST_BIN_NO_TIMEOUT)/fuzzer_$(PROTOCOL) \ -artifact_prefix="$(FUZZER_ARTIFACTS)/$(PROTOCOL)/" \ -max_len=512 $(FUZZER_ARGUMENTS) \ -max_total_time=$(FUZZER_TIMEOUT) \ @@ -101,7 +101,7 @@ endif test.fuzzer.$(PROTOCOL).merge: | src/tests/fuzzer-corpus/$(PROTOCOL) @echo MERGE-FUZZER-CORPUS $(PROTOCOL) ${Q}[ -e "$(FUZZER_CORPUS_DIR)/$(PROTOCOL)_new" ] || mkdir "$(FUZZER_CORPUS_DIR)/$(PROTOCOL)_new" - ${Q}$(TEST_BIN)/fuzzer_$(PROTOCOL) \ + ${Q}$(TEST_BIN_NO_TIMEOUT)/fuzzer_$(PROTOCOL) \ -D share/dictionary \ -max_len=512 $(FUZZER_ARGUMENTS) \ -merge=1 \ @@ -113,7 +113,7 @@ test.fuzzer.$(PROTOCOL).merge: | src/tests/fuzzer-corpus/$(PROTOCOL) ${Q}rm -rf "$(FUZZER_CORPUS_DIR)/$(PROTOCOL)_new" test.fuzzer.$(PROTOCOL).crash: $(wildcard $(BUILD_DIR)/fuzzer/$(PROTOCOL)/crash-*) $(wildcard $(BUILD_DIR)/fuzzer/$(PROTOCOL)/timeout-*) $(wildcard $(BUILD_DIR)/fuzzer/$(PROTOCOL)/slow-unit-*) $(TEST_BIN_DIR)/fuzzer_$(PROTOCOL) | src/tests/fuzzer-corpus/$(PROTOCOL) - $(TEST_BIN)/fuzzer_$(PROTOCOL) \ + $(TEST_BIN_NO_TIMEOUT)/fuzzer_$(PROTOCOL) \ -artifact_prefix="$(FUZZER_ARTIFACTS)/$(PROTOCOL)/" \ -max_len=512 $(FUZZER_ARGUMENTS) \ -max_total_time=$(FUZZER_TIMEOUT) \ diff --git a/src/lib/util/debug.c b/src/lib/util/debug.c index 5f68ada62c7..6c9536e439e 100644 --- a/src/lib/util/debug.c +++ b/src/lib/util/debug.c @@ -1292,6 +1292,14 @@ int fr_fault_setup(TALLOC_CTX *ctx, char const *cmd, char const *program) #endif #ifdef SIGSEGV if (fr_set_signal(SIGSEGV, fr_fault) < 0) return -1; +#endif +#ifdef SIGALRM + /* + * This is used be jlibtool to terminate + * processes which have been running too + * long. + */ + if (fr_set_signal(SIGALRM, fr_fault) < 0) return -1; #endif break;