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

Gracefully handle deeply nested expressions, instead of blowing the stack #788

Open
yorickpeterse opened this issue Dec 16, 2024 · 0 comments
Labels
accepting contributions Issues that are suitable to be worked on by anybody, not just maintainers bug Defects, unintended behaviour, etc compiler Changes related to the compiler

Comments

@yorickpeterse
Copy link
Collaborator

Please describe the bug

When parsing deeply nested expressions such as {{{{ repeat a lot of times }}}}, it's possible to consume all stack space and trigger a stack overflow. This is because our parser is implemented as a recursive descent parser, and specifically recurses to parse nested expressions.

To prevent this from happening, we should enforce a maximum nesting depth for expressions. This limit should be 64 such that it's unlikely to ever be hit in real code, but still protects against accidents.

This issue was first reported in #782. A (better) proposal on how to resolve this is found in #782 (comment).

Operating system

Fedora

Inko version

main

@yorickpeterse yorickpeterse added accepting contributions Issues that are suitable to be worked on by anybody, not just maintainers bug Defects, unintended behaviour, etc compiler Changes related to the compiler labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepting contributions Issues that are suitable to be worked on by anybody, not just maintainers bug Defects, unintended behaviour, etc compiler Changes related to the compiler
Projects
None yet
Development

No branches or pull requests

1 participant