Comments (4)
I've tried the new commit and it worked great.
I had thought this might be related to antlr since afl hanged when calling antlr4::DefaultErrorStrategy::sync
, but I wasn't aware of the fact that ambiguous grammar rules could cause trouble.
Thank you so much for your help!
from grammar-mutator.
I will take a look later this week.
from grammar-mutator.
My guess is that your python grammar has inappropriate recursive rules. For example,
"<program>": [["<stmt>", "<NEWLINE>"], ["<stmt>", "<NEWLINE>", "<program>"]],
"<decorators>": [["<decorator>"], ["<decorator>", "<decorators>"]],
The two rules for <program>
may result in ambiguity, as they look quite similar. There may exist other recursive rules in your grammar.
I would change them to the following rules to avoid ambiguity:
"<program>": [["<stmt>", "<NEWLINE>", "<program>"], []],
"<decorators>": [["<decorator>", "<decorators>"], []],
This is just my guess, and need to check ANTLR4 documents for more information.
from grammar-mutator.
A temporary workaround is pushed: 4899a2f. You can give it a try.
The new commit fixes a naming issue. Since you are using the grammar generator to generate test cases, the new commit can help you avoid parsing during the initialization stage.
Still, the issue is not fully resolved, as it is actually caused by the ambiguity of the grammar. You can also confirm the infinite loop behavior using ANTLR4:
python grammars/f1_g4_translate.py ./grammars/python.json ./grammars # Generate Grammar.g4
mkdir temp
cd temp
java -jar ../antlr-4.8-complete.jar ../grammars/Grammar.g4
javac -cp "../antlr-4.8-complete.jar:$CLASSPATH" Grammar*.java
java -cp "../antlr-4.8-complete.jar:$CLASSPATH" org.antlr.v4.gui.TestRig Grammar entry -tree -trace ../in/0
# the program will hang here
To fully address your issue, you may want to reach out to the ANTLR4 community for help to diagnose the root cause of the grammar.
from grammar-mutator.
Related Issues (20)
- Grammar Mutator crashes due to null pointer dereference on write_tree_to_file HOT 14
- Wasteful rebuilding of non-terminal trees HOT 4
- Long recursive calls cause afl to segfault HOT 8
- Memory leaks in `splicing_mutation`
- Test compilation error HOT 1
- incorrect rule index deduction from ANTLR HOT 3
- A question about convert the ASCII HOT 9
- A question about data length HOT 2
- Issue with recursive javascript grammar HOT 6
- How to add extras dynamically during fuzzing HOT 2
- Inconsistency between compilations HOT 7
- Grammar mutator issue : _pick_non_term_node HOT 5
- Segmentation fault when dealing with hex-ANSII conversion HOT 12
- Is it possible to automatically eliminate indirect left-recursion HOT 1
- Does this mutator uses genetic algorithm? HOT 1
- optimized syntax '+' cause 'random_recursive_mutation' error HOT 5
- json to g4 only with "parser" cause some syntax error HOT 3
- UnicodeEncodeError HOT 1
- Use of ANTLR grammar instead of json-formatted grammar HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grammar-mutator.