You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Increase rule stack protection limit - Syntax highlighting broken in JS files with multiple nested functions #9937
bugIssue identified by VS Code Team member as probable bugjavascriptJavaScript support issuestokenizationText tokenizationverifiedVerification succeeded
VSCode Version: 1.4.0-insider (anything after the 1.3.x builds, still broken as of the 2016-07-29 build)
OS Version: Windows 7 x64
Steps to Reproduce:
Write some code and continue nesting functions until the syntax highlighting stops working. Once it stops working then it will be broken for the remainder of the file. Two examples are pasted below (obviously the examples are simplified and contrived, but they illustrate the problem):
And just to be clear, this problem was not occurring until the 1.4.x codebase as far as I can remember. In fact the problem does not exist under the current 1.3.1 release.
Unfortunately the problem persists with the public 1.4 release. Have you figured out what is going on yet?
In the meantime, are there links to installers for the previous versions? I don't see v1.3.1 (or anything past 0.10.10) on the Previous Releases wiki page.
Can the limit be increased a small amount? I know the examples seem like corner cases, but I actually have a few files that are affected by this (which is why I tried to create simplified examples in the first place).
changed the title [-]Syntax highlighting broken in JS files with multiple nested functions[/-][+]Increase rule stack protection limit - Syntax highlighting broken in JS files with multiple nested functions[/+]on Aug 5, 2016
Davison Long (@dlong500) This affected one of my projects as well. If you're still looking for the older build of VSCode, they are linked in the updates section of their website 👍
Sorry about these issues, but due to this limit we now get to find out about cases where grammars are broken (forget to pop out their rule stack). It might take a couple of releases, but this will bring our grammars in a better shape ("correct" is a better word than better) which will lead to reduced memory usage and faster tokenization times on the long term.
This issue touches some of files in my current project. VS Code version: 1.4.0. If you have any concerns with tokenization performance could you at least make this feature customizable in settings?
Przemek Szewczyk (@prezmo) Tokenization works based on a stack state machine. We interpret the rules the grammars define and transition between states, and push new states on the stack or pop them. We have received hard to reproduce bugs that were leading to out-of-memory crashes, with their root cause being invalid grammars. Think of it like a stack overflow which leads to OOM. We now have the limit of 30 states on the stack, we can increase this limit, but there are grammars that for each line end up pushing a state and forgetting to pop it. This leads to poor user experience and we get bugs in the form "VSCode feels slow... VSCode crashes randomly... etc" and many of them are due to the invalid grammars we ship with. Adding a limit to the stack size is similar to a stack overflow exception that AFAIK all runtimes throw eventually.
bugIssue identified by VS Code Team member as probable bugjavascriptJavaScript support issuestokenizationText tokenizationverifiedVerification succeeded
Activity
dlong500 commentedon Jul 29, 2016
And just to be clear, this problem was not occurring until the 1.4.x codebase as far as I can remember. In fact the problem does not exist under the current 1.3.1 release.
aeschli commentedon Aug 2, 2016
alexandrudima Alex, is that maybe related to the max number of nested scoped?
dlong500 commentedon Aug 4, 2016
Unfortunately the problem persists with the public 1.4 release. Have you figured out what is going on yet?
In the meantime, are there links to installers for the previous versions? I don't see v1.3.1 (or anything past 0.10.10) on the Previous Releases wiki page.
alexdima commentedon Aug 5, 2016
Martin Aeschlimann (@aeschli) This is my change (if the stack goes above 30 tokenization is aborted, think of it like a stack overflow) - f7d23a3
aeschli commentedon Aug 5, 2016
Ok, I think 30 is reasonable and the example is rather a corner case.
Closing as 'works as expected'.
dlong500 commentedon Aug 5, 2016
Can the limit be increased a small amount? I know the examples seem like corner cases, but I actually have a few files that are affected by this (which is why I tried to create simplified examples in the first place).
alexdima commentedon Aug 5, 2016
Davison Long (@dlong500) Sure
[-]Syntax highlighting broken in JS files with multiple nested functions[/-][+]Increase rule stack protection limit - Syntax highlighting broken in JS files with multiple nested functions[/+]ericfernandez commentedon Aug 6, 2016
Davison Long (@dlong500) This affected one of my projects as well. If you're still looking for the older build of VSCode, they are linked in the updates section of their website 👍
Here is 1.3.1 that isn't affected by this:
https://code.visualstudio.com/updates/June_2016
1 remaining item
dontcryme commentedon Aug 10, 2016
after vscode update,
I have a same problem with 'multiple nested functions'.
if i replace my code
"connection.rollback(function() {
console.error("rollback error"); connection.release(); res.json(-1); return; }); "
with
"connection.rollback(function() { console.error("rollback error"); connection.release(); res.json(-1); return ; });"
everything is alright. (remove newline)
why this happened to me
alexdima commentedon Aug 12, 2016
Sorry about these issues, but due to this limit we now get to find out about cases where grammars are broken (forget to pop out their rule stack). It might take a couple of releases, but this will bring our grammars in a better shape ("correct" is a better word than better) which will lead to reduced memory usage and faster tokenization times on the long term.
dontcryme commentedon Aug 17, 2016
Martin Aeschlimann (@aeschli)
after vscode insider install,
i have a same problem, too.(source code highlighting not work. :-( )
prezmo commentedon Aug 27, 2016
This issue touches some of files in my current project. VS Code version: 1.4.0. If you have any concerns with tokenization performance could you at least make this feature customizable in settings?
Does insider version resolves the issue?
alexdima commentedon Aug 29, 2016
Przemek Szewczyk (@prezmo) Tokenization works based on a stack state machine. We interpret the rules the grammars define and transition between states, and push new states on the stack or pop them. We have received hard to reproduce bugs that were leading to out-of-memory crashes, with their root cause being invalid grammars. Think of it like a stack overflow which leads to OOM. We now have the limit of 30 states on the stack, we can increase this limit, but there are grammars that for each line end up pushing a state and forgetting to pop it. This leads to poor user experience and we get bugs in the form "VSCode feels slow... VSCode crashes randomly... etc" and many of them are due to the invalid grammars we ship with. Adding a limit to the stack size is similar to a stack overflow exception that AFAIK all runtimes throw eventually.
alexdima commentedon Aug 29, 2016
From #10908 ... looks like the JS grammar pushes +4 rules per embedded function.
alexdima commentedon Aug 29, 2016
From #10567 ... The maximum reached depth is 31
dlong500 commentedon Aug 30, 2016
Great! It's now fixed as far as I can tell for my projects. I think the increased limit should be more than I would ever need (hopefully).
Fixes microsoft#9937: Increase the stack protection limit from 30 to 100