Repository navigation
fix(stdlib): charge pattern matching to the budget and cap table element ranges - #447
Open
adriencohen wants to merge 2 commits into
Open
adriencohen wants to merge 2 commits into
adriencohen wants to merge 2 commits into
Conversation
… depth limits goto loops, __call chains, metamethod work and recursion that re-enters Lua from native code (pcall, stdlib callbacks, Lua.call_function/3 from a host callback) were not charged to :max_instructions or :max_call_depth, so a script could loop or recurse without bound.
…ent ranges Native stdlib work runs outside max_instructions: a backtracking pattern runs for minutes, table.sort with a comparator is quadratic, and table.unpack accepts ranges of 10 million elements. Stdlib calls now draw on the instruction budget, and the element ceiling is a configurable option.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #446: only the last commit is new.
Native stdlib work runs outside
:max_instructions: a backtracking pattern runs for minutes,table.sortwith a comparator is quadratic, andtable.unpackaccepts ranges of 10 million elements. Stdlib calls now draw on the instruction budget, and the element ceiling is a configurable option.string.find(("a"):rep(30), "a*a*a*a*a*a*a*a*a*a*b"), 10,000-instruction budgettable.sortwith a comparator, 4,000 shuffled elementsBefore is #446. Apple M2, OTP 29.
The new
:max_table_elementsoption defaults to 1,000,000 (PUC-Lua's stack limit), down from the fixed 10,000,000.table.sortwith a comparator is now a merge sort, so the comparator is called in a different order.string.packwith a hugec<n>field,utf8.offsetand greedy pattern scans still do their work before it is charged.