Integrated: 8373448: jpackage: StackOverflowError when processing a very long argument

Alexey Semenyuk asemenyuk at openjdk.org
Fri Jan 9 14:52:32 UTC 2026


On Thu, 8 Jan 2026 04:44:55 GMT, Alexey Semenyuk <asemenyuk at openjdk.org> wrote:

> Replace reluctant quantifier `*?` with the possessive alternative (`*+`) and get rid of back-references from the regexp tokenizing a value of the "--arguments" option into a string array to fix the catastrophic backtracking resulting in a stack overflow.
> 
> Old regexp: `(?:(?:(["'])(?:\\\1|.)*?(?:\1|$))|(?:\["'\s]|[^\s]))++`
> 
> New regexp `(?:(?:(?:'(?:\'|[^'])*+(?:'|$))|(?:"(?:\"|[^"])*+(?:"|$)))|(?:\["'\s]|\S))++`
> 
> Add test cases that pass both the old and the new variants of the regexp, except for the last test case that causes a stack overflow with the old regexp.
> 
> The initial intention was to replace the regexp with the tokenizer function. It was abandoned in favor of reworking the regexp to minimize the risk of regressions.

This pull request has now been integrated.

Changeset: 8737a8ca
Author:    Alexey Semenyuk <asemenyuk at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/8737a8ca73952d60129e7fc2f7e17eea3b800af7
Stats:     37 lines in 2 files changed: 31 ins; 0 del; 6 mod

8373448: jpackage: StackOverflowError when processing a very long argument

Reviewed-by: almatvee

-------------

PR: https://git.openjdk.org/jdk/pull/29104


More information about the core-libs-dev mailing list