RFR: 8373448: jpackage: StackOverflowError when processing a very long argument [v2]

Alexey Semenyuk asemenyuk at openjdk.org
Fri Jan 9 00:42:31 UTC 2026


> 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.

Alexey Semenyuk has updated the pull request incrementally with one additional commit since the last revision:

  Remove debug output

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/29104/files
  - new: https://git.openjdk.org/jdk/pull/29104/files/8210135a..d8ebb1dd

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=29104&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=29104&range=00-01

  Stats: 8 lines in 1 file changed: 0 ins; 8 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/29104.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29104/head:pull/29104

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


More information about the core-libs-dev mailing list