GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] UnnecessaryImport: Fix StackOverflowError for very long Javadoc references by adangel · Pull Request #7396 · pmd/pmd

Conversation

@adangel

@adangel adangel commented Nov 26, 2026

Copy link
Copy Markdown
Member

Describe the PR

The Javadoc reference regexes in UnnecessaryImportRule used a repeated group for dotted names. java.util.regex handles such groups recursively, so a comment with thousands of a.a.a. segments (about 4 KB) caused a StackOverflowError, which aborts the analysis unless error recovery mode is on. The pattern now uses possessive quantifiers, so matching is iterative and linear in the input size.

Related issues

  • Reported as a security vulnerability as https://github.com/pmd/pmd/security/advisories/GHSA-64q8-3xx3-mh7q

    • however, the original reporter is not existing anymore ("ghost")
  • Properly described in new security advisory: GHSA-p8c4-pmh9-36vf

  • Fix GHSA-p8c4-pmh9-36vf

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
adangel added 3 commits November 26, 2026 15:15
@adangel
[java] UnnecessaryImport: Fix StackOverflowError for very long Javado…
17ae203
…c references

The Javadoc reference regexes in `UnnecessaryImportRule` used a
repeated group for dotted names. `java.util.regex` handles such
groups recursively, so a comment with thousands of `a.a.a.`
segments (about 4 KB) caused a `StackOverflowError`, which aborts
the analysis unless error recovery mode is on. The pattern now
uses possessive quantifiers, so matching is iterative and
linear in the input size.
@adangel
[java] Optimize regex patterns for improved performance
77f76a5
@adangel
Update release notes and security details
0957d6c
@adangel adangel added this to the 7.30.0 milestone Nov 26, 2026
@adangel adangel added the a:bug PMD crashes or fails to analyse a file. label Nov 26, 2026
@pmd-actions-helper

pmd-actions-helper Bot commented Nov 26, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-11-26 21:10:09+00:00 for 2d45b37)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adangel @claude
[test] Add regression tests for regex StackOverflowError
2d45b37
Regression tests for GHSA-p8c4-pmh9-36vf:

- UnnecessaryImportTest: run the rule via executeRule instead of calling
  visitComments directly (which is private again), use a much longer input
  and assert that imports used inside/after the long reference are not
  reported.
- AvoidUsingHardCodedIPTest, VfUnescapeElTest, AssertionUtilTest: new
  tests with very long inputs for the other fixed patterns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@adangel adangel removed this from the 7.30.0 milestone Nov 27, 2026
@adangel
adangel merged commit fd907c6 into pmd:main Nov 27, 2026
15 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@pmd-actions-helper pmd-actions-helper Bot assigned adangel Nov 27, 2026
@pmd-actions-helper pmd-actions-helper Bot added this to the 7.30.0 milestone Nov 27, 2026
@adangel
adangel deleted the java/unnecessary-import-rule-stackoverflow-error branch November 27, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@adangel adangel

Labels

a:bug PMD crashes or fails to analyse a file.

Projects

None yet

Milestone

7.30.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@adangel
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.