-
-
Notifications
You must be signed in to change notification settings - Fork 200
Description
Description
When two Concerto types form a circular inheritance chain across different namespaces
(e.g. A extends B and B extends A), calling getAllSuperTypeDeclarations() causes
an uncaught Maximum call stack size exceeded error due to infinite recursion.
The self-extension check in validate() (line 198 of classdeclaration.js) only
catches the trivial direct case (A extends A). It does not detect indirect cycles
spanning multiple model files.
##To find the bug
- Create a model file containing concept A that extends B from another namespace.
- Create a second model file containing concept B that extends A from the first namespace.
- Load both models into the
ModelManagerand callgetAllSuperTypeDeclarations()on either type.
Expected Behavior
The ModelManager should reject the models during validation with an IllegalModelException indicating a cyclic inheritance pattern, or return an error synchronously.
IllegalModelException: Cyclic inheritance detected for type "org.a@1.0.0.A"
Current Behavior
The Node process crashes with an infinite loop stack overflow.
RangeError: Maximum call stack size exceeded
at ClassDeclaration.getAllSuperTypeDeclarations (/packages/concerto-core/lib/introspect/classdeclaration.js:488)
Root Cause
- The root of the issue is that
getAllSuperTypeDeclarations()in classdeclaration.js walks the supertype chain with no visited-set guard to detect cycles. - This vulnerability to cyclic recursion also exists in
getProperties()andgetIdentifierFieldName()which recursively walk the supertype chain without tracking already-visited nodes.