Closed GoogleCodeExporter closed 9 years ago
Okay, the problem actually may be quite straightforward. In the
copySubgraphRecur
method, there is nothing to detect a cycle; no markers to let us know that
we've gone
around the loop once already, so it will just go around forever.
copySubgrpahRecur is
only called for finally blocks, and therefore this bug will only occur if there
is a
finally block with a loop in it. This example finds the bug too:
void foo() {
try {
return;
} finally {
while(true) {
System.out.println("Yes");
}
}
}
Original comment by nels.bec...@gmail.com
on 22 Feb 2010 at 6:31
Here is a patch. Does this work?
Index: EclipseCFG.java
===================================================================
--- EclipseCFG.java (revision 289)
+++ EclipseCFG.java (working copy)
@@ -345,7 +345,13 @@
clone.setName(current.getName());
cloneMap.put(current, clone);
- if (current == stopNode || node instanceof ReturnStatement
+ if( cloneMap.containsKey(current) ) {
+ if( cloneMap.get(current).equals(clone) ) {
+ // We've already been to this...
+ return clone;
+ }
+ }
+ else if (current == stopNode || node instanceof ReturnStatement
|| node instanceof ThrowStatement || node instanceof
BreakStatement
|| node instanceof ContinueStatement) {
for (EclipseCFGEdge edge : current.getOutputs()) {
Original comment by nels.bec...@gmail.com
on 22 Feb 2010 at 6:36
The previous patch does seem to work on 'foo()' example above...
Original comment by nels.bec...@gmail.com
on 22 Feb 2010 at 6:37
It breaks one of the existing tests though. I need to install the dot viewer on
my new
version of eclipse to find out what's going on.
Original comment by ciera.christopher
on 22 Feb 2010 at 6:47
My mistake on that test. Verified fix, and test is committed.
Original comment by ciera.christopher
on 25 Feb 2010 at 10:33
Awsum!
Original comment by nels.bec...@gmail.com
on 26 Feb 2010 at 9:03
Original issue reported on code.google.com by
nels.bec...@gmail.com
on 19 Feb 2010 at 3:23Attachments: