Skip to content

fix: prevent StackOverflowError converting large mSync values#2269

Merged
caalador merged 1 commit into
mainfrom
fix/2266-regexp
Jun 23, 2026
Merged

fix: prevent StackOverflowError converting large mSync values#2269
caalador merged 1 commit into
mainfrom
fix/2266-regexp

Conversation

@tltv

@tltv tltv commented Jun 22, 2026

Copy link
Copy Markdown
Member

MSYNC_INPUT_VALUE_PATTERN matched the JSON value with the group ((?:[^"\]|\.)*). On OpenJDK this quantified alternation recurses once per repetition, so a large mSync value (e.g. a big text-area payload in a recorded UIDL POST) exhausts the call stack and the HAR-to-k6 conversion dies with a StackOverflowError.

Replace the group with ((?:[^"\]++|\.)*+), using a possessive quantifier on the character class and a possessive outer star. The non-quote/ non-backslash runs are now consumed in a single pass with no backtracking, eliminating the per-character recursion. The match and capture semantics are unchanged: it still captures any run of non-"/non-\ characters and \-escapes up to the closing quote.

Add HarToK6ConverterTest#largeMsyncValueDoesNotOverflowStack.

Fixes: #2266

MSYNC_INPUT_VALUE_PATTERN matched the JSON value with the group
((?:[^"\]|\.)*). On OpenJDK this quantified alternation recurses once
per repetition, so a large mSync value (e.g. a big text-area payload in a
recorded UIDL POST) exhausts the call stack and the HAR-to-k6 conversion
dies with a StackOverflowError.

Replace the group with ((?:[^"\]++|\.)*+), using a possessive quantifier
on the character class and a possessive outer star. The non-quote/
non-backslash runs are now consumed in a single pass with no backtracking,
eliminating the per-character recursion. The match and capture semantics
are unchanged: it still captures any run of non-"/non-\ characters and
\-escapes up to the closing quote.

Add HarToK6ConverterTest#largeMsyncValueDoesNotOverflowStack.

Fixes: #2266
@mcollovati mcollovati requested a review from caalador June 22, 2026 11:50
@caalador caalador merged commit 33f4048 into main Jun 23, 2026
10 checks passed
@caalador caalador deleted the fix/2266-regexp branch June 23, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

K6 utillity: mSync regexp pattern can cause StackOverflowException with large inputs

2 participants