Skip to content

ST6RI-939 Fix StackOverflow when loading a ResourceSet - #770

Merged
seidewitz merged 1 commit into
masterfrom
ST6RI-939
Jul 22, 2026
Merged

ST6RI-939 Fix StackOverflow when loading a ResourceSet#770
seidewitz merged 1 commit into
masterfrom
ST6RI-939

Conversation

@AxelRICHARD

@AxelRICHARD AxelRICHARD commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Fix a StackOverflowError when loading a ResourceSet containing TransitionUsage elements.

Context

Loading a SysML-XMI ResourceSet can trigger a StackOverflowError when derived properties are evaluated on TransitionUsage elements.

The recursion involves the derived transition properties and the implicit member computation performed by TransitionUsageAdapter, especially around:

  • TransitionUsage::source
  • TransitionUsage::sourceFeature()
  • TransitionUsage::succession
  • Implicit transition members and binding connectors

Observed Behavior

The application fails with a recursive stack similar to:

java.lang.StackOverflowError
  at org.omg.sysml.delegate.setting.TransitionUsage_source_SettingDelegate.basicGet(...)
  at org.omg.sysml.lang.sysml.impl.TransitionUsageImpl.getSource(...)
  at org.omg.sysml.adapter.TransitionUsageAdapter.computeTransitionLinkConnectors(...)
  at org.omg.sysml.adapter.TransitionUsageAdapter.addAdditionalMembers(...)
  at org.omg.sysml.util.NamespaceUtil.addAdditionalMembersTo(...)
  at org.omg.sysml.util.UsageUtil.getSourceFeatureOf(...)
  at org.omg.sysml.lang.sysml.impl.TransitionUsageImpl.sourceFeature(...)
  at org.omg.sysml.delegate.setting.TransitionUsage_source_SettingDelegate.basicGet(...)
  ...

SysML-Level Explanation

In SysML, TransitionUsage::source is a derived property. It is computed from sourceFeature(), which identifies the feature used as the source of the transition succession.

At the same time, TransitionUsageAdapter may add implicit members required by transition semantics, such as:

  • the implicit source member;
  • transition link connectors;
  • binding connectors between the succession, the transition link, and parameters.

The issue is that this implicit member computation is not reentrant-safe.

Recursion Cycle

The problematic cycle is:

  1. Code reads transition.getSource().
  2. This evaluates the derived property TransitionUsage::source.
  3. The derived property calls transition.sourceFeature().
  4. sourceFeature() delegates to UsageUtil.getSourceFeatureOf(transition).
  5. UsageUtil.getSourceFeatureOf(...) calls NamespaceUtil.addAdditionalMembersTo(transition).
  6. TransitionUsageAdapter.addAdditionalMembers() calls computeTransitionLinkConnectors().
  7. computeTransitionLinkConnectors() reads transition.getSource().
  8. The same cycle starts again.

This leads to unbounded recursion and eventually a StackOverflowError.

Typical Trigger

The issue can occur when a TransitionUsage has parameters, but its succession-related implicit members are not fully available at the time source is evaluated.

In that state, computeTransitionLinkConnectors() attempts to compute source-related binding connectors and reads transition.getSource(), which re-enters the same implicit member computation.

Changes

Added a Boolean isComputingTransitionLinkConnectors that is set to true during the computation of transition link connectors and reset to false when the computation is done. However, if computeTransitionLinkConnectors ends up being recursively called, it returns without calling TransitionUsage.getSource().

Signed-off-by: Axel RICHARD <axel.richard@obeo.fr>
@AxelRICHARD AxelRICHARD added the bug Something isn't working label Jun 17, 2026
@AxelRICHARD AxelRICHARD added this to the 2026-05 milestone Jun 17, 2026
@AxelRICHARD
AxelRICHARD marked this pull request as ready for review June 17, 2026 07:56
@seidewitz seidewitz removed this from the 2026-05 milestone Jun 17, 2026
@seidewitz
seidewitz marked this pull request as draft June 17, 2026 15:29
@seidewitz
seidewitz force-pushed the master branch 2 times, most recently from 00acc2f to 2a8e96c Compare July 2, 2026 08:31
@AxelRICHARD

Copy link
Copy Markdown
Contributor Author

Hello @seidewitz do you need something else for this pull request? If no, can I set it as "Ready for review"?

@AxelRICHARD
AxelRICHARD marked this pull request as ready for review July 8, 2026 15:39
@seidewitz seidewitz self-assigned this Jul 22, 2026
@seidewitz seidewitz added this to the 2026-07 milestone Jul 22, 2026
@seidewitz
seidewitz self-requested a review July 22, 2026 22:35

@seidewitz seidewitz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Really, this computation needs to be revised so the adding of additional members can be eliminated. For now, though, the simple change proposed in this PR is sufficient.

@seidewitz
seidewitz self-requested a review July 22, 2026 22:40
@seidewitz
seidewitz merged commit 16c2eac into master Jul 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants