From 916548c28cf4f8634979cbb7e5bb4931c7281d09 Mon Sep 17 00:00:00 2001 From: Yannis Guyon Date: Mon, 24 Apr 2023 09:58:43 +0200 Subject: Make kFuzzPxLimit sanitizer dependent Change-Id: Ib70f3c05fc845494c45cb357e70e9602a7e876a3 --- tests/fuzzer/advanced_api_fuzzer.c | 2 +- tests/fuzzer/fuzz_utils.h | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/fuzzer/advanced_api_fuzzer.c b/tests/fuzzer/advanced_api_fuzzer.c index e60840dd..1378d0bc 100644 --- a/tests/fuzzer/advanced_api_fuzzer.c +++ b/tests/fuzzer/advanced_api_fuzzer.c @@ -85,7 +85,7 @@ int LLVMFuzzerTestOneInput(const uint8_t* const data, size_t size) { scaled_height != config.input.height) { // Using the WebPRescalerImport internally can significantly slow // down the execution. Avoid timeouts due to that. - fuzz_px_limit /= 13; + fuzz_px_limit /= 2; } // A big output canvas can lead to out-of-memory and timeout issues, // but a big internal working buffer can too. diff --git a/tests/fuzzer/fuzz_utils.h b/tests/fuzzer/fuzz_utils.h index 713a5f40..3a4c5584 100644 --- a/tests/fuzzer/fuzz_utils.h +++ b/tests/fuzzer/fuzz_utils.h @@ -28,9 +28,20 @@ //------------------------------------------------------------------------------ // Arbitrary limits to prevent OOM, timeout, or slow execution. -// + // The decoded image size, and for animations additionally the canvas size. +// Enabling some sanitizers slow down runtime significantly. +// Use a very low threshold in this case to avoid timeouts. +#if defined(__SANITIZE_ADDRESS__) // GCC +static const size_t kFuzzPxLimit = 1024 * 1024 / 10; +#elif !defined(__has_feature) // Clang static const size_t kFuzzPxLimit = 1024 * 1024; +#elif __has_feature(address_sanitizer) || __has_feature(memory_sanitizer) +static const size_t kFuzzPxLimit = 1024 * 1024 / 10; +#else +static const size_t kFuzzPxLimit = 1024 * 1024; +#endif + // Demuxed or decoded animation frames. static const int kFuzzFrameLimit = 3; -- cgit v1.2.1