Repository navigation
Fix StackOverflowError due to non-commuting TransitionFunctionImpl.combineWith - #281
Merged
swissiety merged 3 commits intoSep 23, 2026
Conversation
marcus-h
commented
Apr 23, 2026
…mbineWith According to the theory, the combineWith operation of the TransitionFunctionImpl class has to be, among other things, commuative. This can result in a StackOverflowError (see VectorTest.testNoStackOverflowDueToNonCommutativeCombineWith for a reproducer). Excerpt from the stack trace: ... at wpds.impl.PostStar.update(PostStar.java:335) at wpds.impl.PostStar$HandleNormalListener.onOutTransitionAdded(PostStar.java:227) at wpds.impl.WeightedPAutomaton.addWeightForTransition(WeightedPAutomaton.java:329) at sync.pds.solver.SyncPDSSolver$4.addWeightForTransition(SyncPDSSolver.java:194) at wpds.impl.PostStar.update(PostStar.java:335) at wpds.impl.PostStar$HandleNormalListener.onOutTransitionAdded(PostStar.java:227) at wpds.impl.WeightedPAutomaton.addWeightForTransition(WeightedPAutomaton.java:329) at sync.pds.solver.SyncPDSSolver$4.addWeightForTransition(SyncPDSSolver.java:194) at wpds.impl.PostStar.update(PostStar.java:335) at wpds.impl.PostStar$HandleNormalListener.onOutTransitionAdded(PostStar.java:227) at wpds.impl.WeightedPAutomaton.addWeightForTransition(WeightedPAutomaton.java:329) at sync.pds.solver.SyncPDSSolver$4.addWeightForTransition(SyncPDSSolver.java:194) at wpds.impl.PostStar.update(PostStar.java:335) at wpds.impl.PostStar$HandleNormalListener.onOutTransitionAdded(PostStar.java:227) at wpds.impl.WeightedPAutomaton.addWeightForTransition(WeightedPAutomaton.java:329) at sync.pds.solver.SyncPDSSolver$4.addWeightForTransition(SyncPDSSolver.java:194) at wpds.impl.PostStar.update(PostStar.java:335) ... When combining the two paths in doSth, a new TransitionFunctionImpl is created where the statement sequences are merged but the stateChangeStatement from one of the path is used. The latter causes the PostStar.update <-> WeightedPAutomaton.addWeightForTransition "ping-pong". In order to fix this, store stateChangeStatement(s) from both paths in a set. Implementation note: a LinkedHashSet is used so the getStateChangeStatement() can be easily implemented (whether the method itself is "meaningful" is debatable, though).
swissiety
requested changes
Apr 27, 2026
Address review: storing every TransitionFunctionImpl's state change statement in a LinkedHashSet costs a set per weight, although only combineWith ever produces more than one statement. TransitionFunctionImpl keeps its single Statement field again, and the new package-private CombinedTransitionFunctionImpl holds the set. combineWith only builds a combined function when the merged set has at least two statements, so combining a function with itself still yields an equal plain TransitionFunctionImpl. A combined function compares its statements as a set, ignoring the order in which they were combined. Combining with ONE (in either order) keeps the combined statements.
swissiety
force-pushed
the
fixStackOverflowError
branch
from
September 23, 2026 12:20
9eb503e to
fe3668a
Compare
swissiety
enabled auto-merge
September 23, 2026 12:20
swissiety
merged commit Sep 23, 2026
bbd8b51
into
secure-software-engineering:develop
9 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.