Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GrammarFuzzer max cost expansion strategy can lead to infinite loops #62

Open
michaelmera opened this issue Nov 29, 2019 · 0 comments
Open
Labels
bug Something isn't working

Comments

@michaelmera
Copy link
Collaborator

The first expansion strategy used by the GrammarFuzzer tries to widen the derivation tree until reaching min_nonterminals unexpanded non-terminals.

There are cases however where it is not possible to create a tree with enough unexpended non-terminals, potentially leading to infinite loops if recursive production rules are chosen, e.g.:

from fuzzingbook.GrammarFuzzer import GrammarFuzzer
from fuzzingbook.ExpectError import ExpectTimeout

grammar = {
    '<start>': ['<A>'],
    '<A>': ['a<A>', 'a'],
}

fuzzer = GrammarFuzzer(grammar, min_nonterminals=2, max_nonterminals=10, log=True)

with ExpectTimeout(2):
    fuzzer.fuzz()

Actually, the current implementation maximizes the risk to encounter these infinite loops because recursive non-terminal expansions are assigned an infinite cost (so they will always be picked first by the max-cost expansion algorithm).

This entire expansion step feels weird to me. Why not go for a (best effort) minimum width for the derivation tree (terminals included) instead of saying that we want to only consider the non-terminals?

@michaelmera michaelmera added the bug Something isn't working label Nov 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant