eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

Stack overflow on closure constraint. #1104

Open eclipse-ocl-bot opened 5 days ago

eclipse-ocl-bot commented 5 days ago

| --- | --- | | Bugzilla Link | 409270 | | Status | NEW | | Importance | P3 normal | | Reported | May 28, 2013 07:52 EDT | | Modified | May 28, 2013 12:50 EDT | | Reporter | Daniel Di Nardo |

Description

Created attachment 231610\ Simple Class diagram

See the attached class diagram.

Given the following constraint:

class SampleNode inv:

let allNodes : Set(SampleNode) = self->closure(prev), \ allNodesWithSameChannelId : Set(SampleNode) = allNodes->select(x : SampleNode | x.channelId = self.channelId), \ orderedNodesWithSameChannelId : OrderedSet(SampleNode) = allNodesWithSameChannelId->sortedBy( index ) \ in

orderedNodesWithSameChannelId->size() > 0

implies

self.frameCount = orderedNodesWithSameChannelId->last().frameCount + 1

The issue I'm having is that while the above constraint works when we evaluate the OCL against a SampleNode instance that has 2500 predecessors, once I increase the number of predecessors to 5000 I get the following error:

Exception in thread "main" java.lang.StackOverflowError\ at java.util.HashMap.getEntry(HashMap.java:344)\ at java.util.HashMap.containsKey(HashMap.java:335)\ at org.eclipse.ocl.AbstractEvaluationEnvironment.add(AbstractEvaluationEnvironment.java:122)\ at org.eclipse.ocl.EvaluationVisitorImpl.visitVariable(EvaluationVisitorImpl.java:2368)\ at org.eclipse.ocl.ecore.impl.VariableImpl.accept(VariableImpl.java:654)\ at org.eclipse.ocl.internal.evaluation.IterationTemplate.initializeIterators(IterationTemplate.java:126)\ at org.eclipse.ocl.internal.evaluation.IterationTemplate.evaluate(IterationTemplate.java:83)\ at org.eclipse.ocl.internal.evaluation.IterationTemplateClosure.evaluateResult(IterationTemplateClosure.java:90)\ at org.eclipse.ocl.internal.evaluation.IterationTemplate.evaluate(IterationTemplate.java:90)\ at org.eclipse.ocl.internal.evaluation.IterationTemplateClosure.evaluateResult(IterationTemplateClosure.java:90)\ at org.eclipse.ocl.internal.evaluation.IterationTemplate.evaluate(IterationTemplate.java:90)\ at org.eclipse.ocl.internal.evaluation.IterationTemplateClosure.evaluateResult(IterationTemplateClosure.java:90)\ at org.eclipse.ocl.internal.evaluation.IterationTemplate.evaluate(IterationTemplate.java:90)

sampleList.png

sampleList.png

eclipse-ocl-bot commented 5 days ago

By Ed Willink on May 28, 2013 12:50

For Set-based closures, it should be easy to change the closure strategy to a breadth-first loop rather than depth-first recursion. Not so obvious how to preserve depth-first ordering efficiently for OrderedSet-based closures.