Skip to content

Bug: Circular inheritance between types causes "Maximum call stack size exceeded" crash #1138

@dhansuhkumar

Description

@dhansuhkumar

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

  1. Create a model file containing concept A that extends B from another namespace.
  2. Create a second model file containing concept B that extends A from the first namespace.
  3. Load both models into the ModelManager and call getAllSuperTypeDeclarations() 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() and getIdentifierFieldName() which recursively walk the supertype chain without tracking already-visited nodes.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions