rhaiscript / lsp

Language server for Rhai.
Apache License 2.0
43 stars 4 forks source link

Parser stack overflow on invalid input #32

Closed tamasfe closed 2 years ago

tamasfe commented 2 years ago

When an unexpected token is encountered, in some cases the parser will try to parse the next rule without consuming the invalid token. This way the parser can be more tolerant to errors and more valid language elements can be recognized in partially valid code. However in some cases this leads to repeatedly trying to parse the same rule leading to either stack overflows or infinite loops.

The cases where a token can be left unconsumed on error should be thoroughly reviewed and used sparingly.

We should also implement fuzz tests to detect these issues.

tamasfe commented 2 years ago

There are now measures implemented to handle these cases, as well as fuzzing is done on the parser.