slint
slint copied to clipboard
Stack overflow with hundreads of { inside slint file
Slint nightly lsp in vscode - 2024-10-08, 18:37:51
crashes with info
thread 'LanguageServer' has overflowed its stack
fatal runtime error: stack overflow
I cannot check code where exactly this panics, because this happens only inside Visual Studio Code
Is there any command that I could to run from cli to reproduce issue? I could minimize output if this would be possible
you can try to run slint-compiler.
Indeed, the compiler is a recursive descent parser and there is no protection for stack overflow when going too deep (thousands of opening braces).
Solution could include:
- Do a pass before the actual parsing counting the number of opening braces and printing an error if this is too big (say a thousand)
- Within the parser, keep a recursion count state, and error if it is too big
- Somehow detect stack overflow through other mean. (how?) and have an error thrown out when we use too much stack instead of a crash.