Skip to content

Commit

Permalink
Increase the default LPeg stack size.
Browse files Browse the repository at this point in the history
It is not clear how large this value should be. It appears to be a function of grammar complexity.

For example, a problematic HTML file requires a value of 1329 to work, but removing either the
'attribute' rule or an embedded lexer reduces the limit.

However, identifying which files trigger a stack overflow is not trivial. It does not appear to
depend on file size. For example, the problematic HTML file is 125K, but a non-problematic HTML
file of 500K works.
  • Loading branch information
orbitalquark committed Sep 13, 2024
1 parent 4b635e3 commit 6d7b5e1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lexers/lexer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,8 @@ local lpeg = lpeg
local P, R, S, V, B = lpeg.P, lpeg.R, lpeg.S, lpeg.V, lpeg.B
local Ct, Cc, Cp, Cmt, C = lpeg.Ct, lpeg.Cc, lpeg.Cp, lpeg.Cmt, lpeg.C

lpeg.setmaxstack(1328) -- the default of 400 is too low for complex grammars

--- Default tags.
local default = {
'whitespace', 'comment', 'string', 'number', 'keyword', 'identifier', 'operator', 'error',
Expand Down

0 comments on commit 6d7b5e1

Please sign in to comment.