Problem
JUnit version: 5.13.0
Jazzer JUnit version: 0.24.0
Currently Jazzer recognizes JUnit's @Timeout annotation, see
|
private static Optional<String> translateJUnitTimeoutToLibFuzzerFlag(ExtensionContext context) { |
This is quite useful for detecting application hangs (e.g. due to infinite loops) detected by Jazzer during fuzzing. For example when you normally expect a single fuzz execution to take a few milliseconds, you can make it fail fast if it unexpectedly takes more than one second.
The problem is that @Timeout is additionally still respected by JUnit and can lead to spurious timeout failures if the complete fuzzing run takes longer.
Example
Consider this example:
@Timeout(value = 2, unit = TimeUnit.SECONDS)
@FuzzTest(maxExecutions = 10)
void test(int ignored) throws Exception {
long start = System.nanoTime();
// Busy wait 1 second
while ((System.nanoTime() - start) / 1_000_000_000 < 1) {
}
}
When run in fuzzing mode each fuzzing execution takes less than the 2 seconds timeout and passes (as desired). However the complete fuzzing run takes ~10 seconds, so JUnit then (erroneously) reports the fuzzing run as failure.
Suggested solution
Maybe instead of (or in addition to?) levaraging JUnit's timeout mechanism it would be better to add a dedicated @FuzzTest parameter, e.g.:
/**
* Timeout for a single fuzzing execution. Only has an effect in fuzzing mode, not in regression mode.
* The timeout format is the same as for {@link #maxDuration()}, for example "1s". An empty string
* (the default) means no timeout.
*/
String executionTimeout() default "";
A nice side effect of this might be that it is easier to discover by users than the current @Timeout support.
Possibly related to #478
Problem
JUnit version: 5.13.0
Jazzer JUnit version: 0.24.0
Currently Jazzer recognizes JUnit's
@Timeoutannotation, seejazzer/src/main/java/com/code_intelligence/jazzer/junit/FuzzTestExecutor.java
Line 140 in efbc635
This is quite useful for detecting application hangs (e.g. due to infinite loops) detected by Jazzer during fuzzing. For example when you normally expect a single fuzz execution to take a few milliseconds, you can make it fail fast if it unexpectedly takes more than one second.
The problem is that
@Timeoutis additionally still respected by JUnit and can lead to spurious timeout failures if the complete fuzzing run takes longer.Example
Consider this example:
When run in fuzzing mode each fuzzing execution takes less than the 2 seconds timeout and passes (as desired). However the complete fuzzing run takes ~10 seconds, so JUnit then (erroneously) reports the fuzzing run as failure.
Suggested solution
Maybe instead of (or in addition to?) levaraging JUnit's timeout mechanism it would be better to add a dedicated
@FuzzTestparameter, e.g.:A nice side effect of this might be that it is easier to discover by users than the current
@Timeoutsupport.Possibly related to #478