New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stack overflow on multi maps (and other non-trivial generic classes) #4357
Comments
I forgot to mention, this only happens on 6.x version, for 5.x it does not fail |
Here's PoC fix: d62cba1 |
Hi @xRodney ! thanks a lot for looking into this! Regarding this issue:
This sounds like a regression in cc. @iocanel |
Hi @andreaTP, At the moment, I don't see a bug in It is possible that there was a change of behavior between versions, perhaps regarding how Visitors handle changes they themselves caused. I'm not that familiar with a history of this project and/or |
From what you said, it sounds like an issue with |
It seems that for some reason, sundrio has a hard time dealing with: public class MyMultiMap<K, V> extends HashMap<K, List<V>> {} Still investigating. |
There really is a bug in sundrio. It took me a while to simulate it, but I was successful in the end. |
Closed by accident, but everything is in the |
I'm confused, does #4403 fix this one (as the PR description says), or are there some pending tasks to complete the fix? |
👍 We'll wait for his feedback then. Tonight's SNAPSHOT should contain the new dependency. |
No, it's not fixed. The fix in sundrio only applies to their To complicate thigs ever further, I am not fully convinced that the fix sundrio/sundrio#334 is, in fact, correct. What they did was to replace mapping I am not sure how much that would matter if we indeed wanted to migrate crd-code to I'll look into this further and I'll put some more comments to sundrio/sundrio#333 if I find something. |
…ses) Logic in sundrio that is responsible for replacing generic type arguments on methods and properties with their concrete instantiations from subclasses contained a bug, in which it looped infinitely if the same type argument name was used at multiple classes in the hierarchy. A common occurence were multimaps. A very similar code was also present in crd-generator, also suffering from the same bug. Sundrio has been updated to account for this situation, and updated utilities from sundrio have been introduced to crd-generator, which replace the previous implementation of teh same algorithm. Fixes fabric8io#4357
…ses) Logic in sundrio that is responsible for replacing generic type arguments on methods and properties with their concrete instantiations from subclasses contained a bug, in which it looped infinitely if the same type argument name was used at multiple classes in the hierarchy. A common occurence were multimaps. A very similar code was also present in crd-generator, also suffering from the same bug. Sundrio has been updated to account for this situation, and updated utilities from sundrio have been introduced to crd-generator, which replace the previous implementation of teh same algorithm. Fixes fabric8io#4357
Update: I have made a PR to sundrio, fixing the issue (sundrio/sundrio#340). I have also made a PR here, which however relies on the changed code, so it won't compile for you. But locally it seems to be working. |
I guess we need to wait on Sundrio release to complete this fix |
ping @iocanel would you have the time to cut a release of |
…ses) Logic in sundrio that is responsible for replacing generic type arguments on methods and properties with their concrete instantiations from subclasses contained a bug, in which it looped infinitely if the same type argument name was used at multiple classes in the hierarchy. A common occurence were multimaps. A very similar code was also present in crd-generator, also suffering from the same bug. Sundrio has been updated to account for this situation, and updated utilities from sundrio have been introduced to crd-generator, which replace the previous implementation of teh same algorithm. Fixes fabric8io#4357
…ses), schema for multimaps is wrong Logic in sundrio that is responsible for replacing generic type arguments on methods and properties with their concrete instantiations from subclasses contained a bug, in which it looped infinitely if the same type argument name was used at multiple classes in the hierarchy. A common occurence were multimaps. A very similar code was also present in crd-generator, also suffering from the same bug. Sundrio has been updated to account for this situation, and updated utilities from sundrio have been introduced to crd-generator, which replace the previous implementation of the same algorithm. A test has been added to validate that multimaps (like `class MultiMap<K,V> implements Map<K,List<V>>`) are generated correctly. Fixes fabric8io#4357 Fixes fabric8io#4487
…es), schema for multimaps is wrong Logic in sundrio that is responsible for replacing generic type arguments on methods and properties with their concrete instantiations from subclasses contained a bug, in which it looped infinitely if the same type argument name was used at multiple classes in the hierarchy. A common occurence were multimaps. A very similar code was also present in crd-generator, also suffering from the same bug. Sundrio has been updated to account for this situation, and updated utilities from sundrio have been introduced to crd-generator, which replace the previous implementation of the same algorithm. A test has been added to validate that multimaps (like `class MultiMap<K,V> implements Map<K,List<V>>`) are generated correctly. Fixes fabric8io#4357 Fixes fabric8io#4487
…es), schema for multimaps is wrong Logic in sundrio that is responsible for replacing generic type arguments on methods and properties with their concrete instantiations from subclasses contained a bug, in which it looped infinitely if the same type argument name was used at multiple classes in the hierarchy. A common occurence were multimaps. A very similar code was also present in crd-generator, also suffering from the same bug. Sundrio has been updated to account for this situation, and updated utilities from sundrio have been introduced to crd-generator, which replace the previous implementation of the same algorithm. A test has been added to validate that multimaps (like `class MultiMap<K,V> implements Map<K,List<V>>`) are generated correctly. Fixes fabric8io#4357 Fixes fabric8io#4487
…es), schema for multimaps is wrong Logic in sundrio that is responsible for replacing generic type arguments on methods and properties with their concrete instantiations from subclasses contained a bug, in which it looped infinitely if the same type argument name was used at multiple classes in the hierarchy. A common occurence were multimaps. A very similar code was also present in crd-generator, also suffering from the same bug. Sundrio has been updated to account for this situation, and updated utilities from sundrio have been introduced to crd-generator, which replace the previous implementation of the same algorithm. A test has been added to validate that multimaps (like `class MultiMap<K,V> implements Map<K,List<V>>`) are generated correctly. Fixes fabric8io#4357 Fixes fabric8io#4487
ping @andreaTP, sundrio has been released and the linked PR is ready for review |
…es), schema for multimaps is wrong Logic in sundrio that is responsible for replacing generic type arguments on methods and properties with their concrete instantiations from subclasses contained a bug, in which it looped infinitely if the same type argument name was used at multiple classes in the hierarchy. A common occurence were multimaps. A very similar code was also present in crd-generator, also suffering from the same bug. Sundrio has been updated to account for this situation, and updated utilities from sundrio have been introduced to crd-generator, which replace the previous implementation of the same algorithm. A test has been added to validate that multimaps (like `class MultiMap<K,V> implements Map<K,List<V>>`) are generated correctly. Fixes fabric8io#4357 Fixes fabric8io#4487
…es), schema for multimaps is wrong Logic in sundrio that is responsible for replacing generic type arguments on methods and properties with their concrete instantiations from subclasses contained a bug, in which it looped infinitely if the same type argument name was used at multiple classes in the hierarchy. A common occurence were multimaps. A very similar code was also present in crd-generator, also suffering from the same bug. Sundrio has been updated to account for this situation, and updated utilities from sundrio have been introduced to crd-generator, which replace the previous implementation of the same algorithm. A test has been added to validate that multimaps (like `class MultiMap<K,V> implements Map<K,List<V>>`) are generated correctly. Fixes fabric8io#4357 Fixes fabric8io#4487
…es), schema for multimaps is wrong Logic in sundrio that is responsible for replacing generic type arguments on methods and properties with their concrete instantiations from subclasses contained a bug, in which it looped infinitely if the same type argument name was used at multiple classes in the hierarchy. A common occurence were multimaps. A very similar code was also present in crd-generator, also suffering from the same bug. Sundrio has been updated to account for this situation, and updated utilities from sundrio have been introduced to crd-generator, which replace the previous implementation of the same algorithm. A test has been added to validate that multimaps (like `class MultiMap<K,V> implements Map<K,List<V>>`) are generated correctly. Fixes #4357 Fixes #4487
Describe the bug
Hi,
while I was testing my other work (#4354) against Keycloak operator schema, I noticed another issue. The schema generation fails with StackOverflowError.
Upon closer inspection, it looks that the problematic part is their usage of concrete multi maps like so:
Fabric8 Kubernetes Client version
6.0.0
Steps to reproduce
Here's a minimal failing example:
Unfortunately, this cannot be avoided by using
@SchemaFrom
or@SchemaSwap
annotations, because the Stack Overflow happens an a code path that does not process these annotations, namely inAnnotatedPropertyPathDetector
And it is not even necessary to run the full schema generation.
All that is needed to trigger the Stack Overflow (i.e. from a unit test) is:
Expected behavior
The problem is in the unschallow logic, implemented in
Types
class.For generic types, the methods
projectSuperClasses
,projectDefinition
,mapClassRefArguments
andmapGenericProperties
replace type parameters on superclasses with their concrete instantiations from usage site.For simple types, like
class IntStringMap extends HashMap<Integer,String>
, this works by first creating a mapping{K -> Integer, V -> String}
and thein recursively replacing all usages ofK
andV
according to the mapping.However, in our case, the mapping contains
V -> List<V>
. This gets expanded infinitely toList<List<List<...>>>
, until memory is exhausted.Obviously, expected behavior is for this to not happen, the
V
should only be expanded once.Runtime
other (please specify in additional context)
Kubernetes API Server version
other (please specify in additional context)
Environment
other (please specify in additional context)
Fabric8 Kubernetes Client Logs
No response
Additional context
I think I may have a fix for the StackOverflowError, we can discuss that further, just please confirm that somebody else is not working on it already.
As a side note, even with that fixed, multimaps are still generated wrong. I may have a cure for that, too, but I'd create a separate issue.
The text was updated successfully, but these errors were encountered: