AFLplusplus / AFLplusplus/Grammar-Mutator

optimized syntax '+' cause 'random_recursive_mutation' error

オープン
#42 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
274
フォーク
24
PR マージ指標
30日以内にマージされた PR はありません

説明

going further, I found a way to mitigate;

based on the above issues, we create simpler test cases, `test.json`:
```
{
"": [["I ", "", "like C++\n"]],
"": [["", ""], []],
"": [["very "]]
}
```

tanslate to `test.g4`:
```
grammar test;
entry: 'I ' stmt1 'like C++\n' EOF
;
stmt1:
| NODE stmt1
;
NODE : 'very '
;
```

and input `40960_very.txt`:
```
I very very ...(*40956)... very very like C++
```

running with `antlr4-parse`:
![Screen Shot 2024-01-08 at 17 56 39](https://github.com/AFLplusplus/Grammar-Mutator/assets/21287921/b507416e-4668-4cc6-8964-6f144416fc4b)

from the perspective of antlr4, we can use the `+` syntax to describe `test.g4`, and ignore this prefix matching, as follows `test.g4`:
```
grammar test;
entry: 'I ' stmt1 'like C++\n' EOF
;
stmt1:
| (NODE)+
;
NODE : 'very '
;
```

running again with `antlr4-parse`:
![Screen Shot 2024-01-08 at 17 59 40](https://github.com/AFLplusplus/Grammar-Mutator/assets/21287921/a0745df3-c0ee-4ccc-ac94-e88ee053dc85)

so I made a patch to implement the above ideas, please refer to https://github.com/0x7Fancy/Grammar-Mutator/commit/6eae7d14f579b4d3d1196fc1a288c61044a1afe1;

I have only implemented the optimization of head recursion and tail recursion here, which is simple and easy to understand. for intermediate recursion, I think it can be rewritten as head/tail recursion in json

of course, this is just a mitigation measure. When the mutation generates a sufficiently complex syntax tree, it may still cause antlr4 to get stuck in syntax parsing.

_Originally posted by @0x7Fancy in https://github.com/AFLplusplus/Grammar-Mutator/issues/17#issuecomment-1880701080_

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。