rohanpadhye/JQF

In the ZestGuidance Class, there may be a potential issue in the calcalation of `this.branchCount` within the `handleEvent` function.

fe1w0 opened this issue · 2 comments

fe1w0 commented

Orignoal soucre code is following:

   // fuzz/src/main/java/edu/berkeley/cs/jqf/fuzz/ei/ZestGuidance.java
    protected void handleEvent(TraceEvent e) {
        conditionallySynchronize(multiThreaded, () -> {
            // Collect totalCoverage
            ((Coverage) runCoverage).handleEvent(e);
            // Check for possible timeouts every so often
            if (this.singleRunTimeoutMillis > 0 &&
                    this.runStart != null && (++this.branchCount) % 10_000 == 0) {
                long elapsed = new Date().getTime() - runStart.getTime();
                if (elapsed > this.singleRunTimeoutMillis) {
                    throw new TimeoutException(elapsed, this.singleRunTimeoutMillis);
                }
            }
        });
    }

The optimization of short-circuit evaluation can result in this.branchCount not being incremented.

The short-circuiting is intentional. When runStart is null, we are not within a test method, so we don't want to count branches.

fe1w0 commented

Thank you for your explanation, got it.