slint icon indicating copy to clipboard operation
slint copied to clipboard

Stack overflow with hundreads of { inside slint file

Open qarmin opened this issue 1 year ago • 2 comments

Slint nightly lsp in vscode - 2024-10-08, 18:37:51

a.slint.zip

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

qarmin avatar Oct 08 '24 17:10 qarmin

Is there any command that I could to run from cli to reproduce issue? I could minimize output if this would be possible

qarmin avatar Oct 08 '24 20:10 qarmin

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.

ogoffart avatar Oct 09 '24 07:10 ogoffart