Repository navigation
<regex>: Revise complexity limit - #6005
Merged
Stephan T. Lavavej (StephanTLavavej) merged 5 commits intoJan 15, 2026
Merged
Stephan T. Lavavej (StephanTLavavej) merged 5 commits into
Stephan T. Lavavej (StephanTLavavej) merged 5 commits into
Conversation
<regex>: Revise complexity limit<regex>: Revise complexity limit
This comment was marked as resolved.
This comment was marked as resolved.
Author
|
I guess we could also use The current solution just avoids this clamping. |
Author
|
I pushed an alternative implementation of the complexity limit using a |
Stephan T. Lavavej (StephanTLavavej)
approved these changes
Jan 13, 2026
Member
|
Thanks! 😻 The single |
Member
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Stephan T. Lavavej (StephanTLavavej)
merged commit Jan 15, 2026
e98005d
into
microsoft:main
45 checks passed
Member
🕵️ 📈 🛑 |
This was referenced Oct 5, 2026
Alexandros Konstantonis (alexandrosk0)
added a commit
to alexandrosk0/Smatchet
that referenced
this pull request
Oct 6, 2026
…skip formats a line cannot match (#2312) Built with MSVC 14.51 or newer, whose STL allows one regex_search call 300000 + 256 * length state transitions in total (microsoft/STL#6005), ParseCallstackText let std::regex_error escape on lines its three format regexes scan without matching. The windows-11-arm runner image moved to that toolset on 2026-09-30, which turned the Windows-on-ARM lane red on every develop run since. The parser's one product caller runs on the UI thread with no try/catch. - Every regex_search in TryParsePathLinePair goes through RegexSearchNoThrow. A search the matcher refuses counts as "this format did not match": the remaining formats still run and nothing leaves the parser. The parser stays Logger-free because the fuzz target links it without a logger. - A format's regex runs only when the line holds the pair its line-number capture needs: '(' then a digit for the MSVC format, ':' then a digit for the other two. The patterns now capture [0-9]+, so that test and the regexes agree in any locale. Results are unchanged for every line the old parser handled: old and new parsers give byte-identical output over 400,000 generated lines on the old-limit STL. Known limit, tracked in #2311: under the 14.51 limit a real MSVC-format frame behind an unbroken token of about 384+ characters on the same line is dropped, because the first format gives up before reaching it. Also adds an infra backlog entry on why a runner-image change sat red on a push-only lane for 12 develop runs. Fixes #2303 Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
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.
Resolves #5944.
This limits the number of state transitions by a complexity limit that grows linearly in the length of the input string. Additionally, this also takes into account the length of string comparisons in
_N_strand_N_backnodes (though divided by 64, as comparing one character is much cheaper than a single state transition).I implemented a complexity limit of
300000 + 256 * input string length. I think that should be enough for reasonable uses (and it's likely this limit will become more generous in practice when #5971 is addressed): Matching the regexa*currently performs about 3 state transitions per matched character, so 85 such loops can be tried before a complexity exception is thrown.The limit might be larger than what can fit into
_Iter_diff_t<_It>(orptrdiff_t). For this reason, two counter variables are used to implement the limit.Drive-by change: I somehow missed that
_Matcher3::_Pop_frame()is no longer in use, so this PR removes this function as well.