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

Document Tact's parser limits for deeply nested expressions #1099

Closed
anton-trunov opened this issue Nov 28, 2024 · 0 comments · Fixed by #1101
Closed

Document Tact's parser limits for deeply nested expressions #1099

anton-trunov opened this issue Nov 28, 2024 · 0 comments · Fixed by #1101
Assignees
Labels
docs.tact-lang.org Documentation for docs.tact-lang.org kept in docs folder scope: parser
Milestone

Comments

@anton-trunov
Copy link
Member

The‬‭ Ohm parser generator uses recursion to parse nested items in expressions and throws a‬ stack overflow exception for deeply nested expression like the following:

contract Foo {
    get fun foo(): Int { return 
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
        1
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
    }
}

Here is the exact error message:

💼 Compiling project test ...
Tact compilation failed
RangeError: Maximum call stack size exceeded
    at Apply.evalOnce (/Users/anton-m1/ton/tact/node_modules/ohm-js/dist/ohm.cjs:2252:36)
    at Apply.reallyEval (/Users/anton-m1/ton/tact/node_modules/ohm-js/dist/ohm.cjs:2192:20)
    at Apply.eval (/Users/anton-m1/ton/tact/node_modules/ohm-js/dist/ohm.cjs:2147:14)
    at MatchState.eval (/Users/anton-m1/ton/tact/node_modules/ohm-js/dist/ohm.cjs:3474:22)
    at Alt.eval (/Users/anton-m1/ton/tact/node_modules/ohm-js/dist/ohm.cjs:2019:15)
    at MatchState.eval (/Users/anton-m1/ton/tact/node_modules/ohm-js/dist/ohm.cjs:3474:22)
    at Apply.evalOnce (/Users/anton-m1/ton/tact/node_modules/ohm-js/dist/ohm.cjs:2256:13)
    at Apply.reallyEval (/Users/anton-m1/ton/tact/node_modules/ohm-js/dist/ohm.cjs:2192:20)
    at Apply.eval (/Users/anton-m1/ton/tact/node_modules/ohm-js/dist/ohm.cjs:2147:14)
    at MatchState.eval (/Users/anton-m1/ton/tact/node_modules/ohm-js/dist/ohm.cjs:3474:22)

This can be mitigated or solved in various ways, but for now we need to document the limitation to finish the security audit process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs.tact-lang.org Documentation for docs.tact-lang.org kept in docs folder scope: parser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants