Skip to content

Fix StackOverflowError due to non-commuting TransitionFunctionImpl.combineWith#281

Open
marcus-h wants to merge 1 commit intosecure-software-engineering:developfrom
marcus-h:fixStackOverflowError
Open

Fix StackOverflowError due to non-commuting TransitionFunctionImpl.combineWith#281
marcus-h wants to merge 1 commit intosecure-software-engineering:developfrom
marcus-h:fixStackOverflowError

Conversation

@marcus-h
Copy link
Copy Markdown

    Fix StackOverflowError due to non-commuting TransitionFunctionImpl.combineWith
    
    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).

…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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant