Skip to content

Commit bb4fe2e

Browse files
authored
Match libfuzzer's timeout for reproduction in centipede (#5291)
Libfuzzer uses `TEST_TIMEOUT - 5`, ignoring fuzzer-defined timeouts, as the per input timeout when reproducing a crash. This PR changes Centipede to also override fuzzer-defined timeouts and use `TEST_TIMEOUT - 5`.
1 parent e30ef54 commit bb4fe2e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

  • src/clusterfuzz/_internal/bot/fuzzers/centipede

src/clusterfuzz/_internal/bot/fuzzers/centipede/engine.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,11 +433,12 @@ def reproduce(self, target_path, input_path, arguments, max_time): # pylint: di
433433
rss_limit = constants.RSS_LIMIT_MB_DEFAULT
434434
if constants.RSS_LIMIT_MB_FLAGNAME in fuzzer_arguments:
435435
rss_limit = fuzzer_arguments[constants.RSS_LIMIT_MB_FLAGNAME]
436-
437-
timeout = constants.TIMEOUT_PER_INPUT_REPR_DEFAULT
438-
if constants.TIMEOUT_PER_INPUT_FLAGNAME in fuzzer_arguments:
439-
timeout = fuzzer_arguments[constants.TIMEOUT_PER_INPUT_FLAGNAME]
440-
436+
# Override fuzzer-defined timeouts to match libfuzzer's behavior in
437+
# https://github.com/google/clusterfuzz/blob/d15a65e7753c6c6579f4b395c40e6d45a7bde262/src/clusterfuzz/_internal/bot/fuzzers/libfuzzer.py#L1255
438+
test_timeout = environment.get_value(
439+
'TEST_TIMEOUT', constants.TIMEOUT_PER_INPUT_REPR_DEFAULT)
440+
# Leave 5 sec buffer for report processing.
441+
timeout = max(1, test_timeout - 5)
441442
os.environ['CENTIPEDE_RUNNER_FLAGS'] = (
442443
f':{constants.RSS_LIMIT_MB_FLAGNAME}={rss_limit}'
443444
f':{constants.TIMEOUT_PER_INPUT_FLAGNAME}={timeout}:')

0 commit comments

Comments
 (0)