Skip to content

GROOVY-11770: StackOverflowError processing generics for kubernetes-c…#2498

Merged
paulk-asert merged 2 commits intoapache:masterfrom
paulk-asert:groovy-11770-cycle-guard
May 2, 2026
Merged

GROOVY-11770: StackOverflowError processing generics for kubernetes-c…#2498
paulk-asert merged 2 commits intoapache:masterfrom
paulk-asert:groovy-11770-cycle-guard

Conversation

@paulk-asert
Copy link
Copy Markdown
Contributor

@paulk-asert paulk-asert commented Apr 28, 2026

…lient library (cycle guard instead of try/catch)

Caveat: the cycle guard uses object identity. If the recursion ever creates fresh ClassNode instances at each level for the same logical pair, identity won't catch it and we'd be back to SOE territory, except now without the catch as a backstop.

We could consider keeping the SOE catch around the recursive call as a final safety net (with a comment like "should be unreachable; cycle guard handles known cases").

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 28, 2026

Codecov Report

❌ Patch coverage is 88.46154% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.2365%. Comparing base (8dde1c8) to head (2588f48).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
.../codehaus/groovy/ast/tools/WideningCategories.java 88.4615% 0 Missing and 3 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2498        +/-   ##
==================================================
+ Coverage     67.2264%   67.2365%   +0.0101%     
- Complexity      31984      31988         +4     
==================================================
  Files            1468       1468                
  Lines          123923     123946        +23     
  Branches        22251      22257         +6     
==================================================
+ Hits            83309      83337        +28     
+ Misses          33433      33428         -5     
  Partials         7181       7181                
Files with missing lines Coverage Δ
.../codehaus/groovy/ast/tools/WideningCategories.java 83.2714% <88.4615%> (+0.8714%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Addresses GROOVY-11770 by preventing StackOverflowError during generics LUB (lowest-upper-bound) computation (notably seen with kubernetes client types) via an explicit recursion/cycle guard rather than relying on catching SOE.

Changes:

  • Add a new STC regression test that exercises an F-bounded generic LUB cycle through a wrapper type.
  • Introduce a LowestUpperBoundContext to track in-flight (t1, t2) LUB computations and break recursion cycles during LUB parameterization.
  • Refactor lowestUpperBound(ClassNode, ClassNode) to route through a context-aware private overload.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/test/groovy/groovy/transform/stc/GenericsSTCTest.groovy Adds GROOVY-11770 regression test intended to ensure LUB computation does not overflow the stack.
src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java Adds identity-based cycle guard context for recursive LUB parameterization; removes SOE catch.

Comment thread src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java Outdated
Comment thread src/test/groovy/groovy/transform/stc/GenericsSTCTest.groovy Outdated
Comment thread src/main/java/org/codehaus/groovy/ast/tools/WideningCategories.java
@paulk-asert paulk-asert force-pushed the groovy-11770-cycle-guard branch 2 times, most recently from d50f236 to 5cd4291 Compare May 2, 2026 03:13
…lient library (cycle guard instead of try/catch)
@paulk-asert paulk-asert force-pushed the groovy-11770-cycle-guard branch from 5cd4291 to 2588f48 Compare May 2, 2026 03:16
@paulk-asert paulk-asert merged commit 42b9d17 into apache:master May 2, 2026
25 checks passed
@paulk-asert paulk-asert deleted the groovy-11770-cycle-guard branch May 2, 2026 05:47
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.

3 participants