- edited description
Infinite recursion in ClassFile.foreachNestedClasses
FindRealBugs currently crashes when analyzing most projects of the Qualitas Corpus, due to infinite recursion in ClassFile.foreachNestedClasses
.
I have attached an example set of class files from the ant project. Corresponding source code: http://grepcode.com/file/repo1.maven.org/maven2/org.apache.ant/ant/1.8.4/org/apache/tools/ant/util/ResourceUtils.java#ResourceUtils
Output of ShowInnerClassesAttribute
from OPAL's Demos project:
org/apache/tools/ant/util/ResourceUtils:
InnerClass(type=org.apache.tools.ant.util.ResourceUtils$ResourceSelectorProvider,outerType=Some(org.apache.tools.ant.util.ResourceUtils),innerName=Some(ResourceSelectorProvider),accessFlags="public static [INTERFACE] abstract")
InnerClass(type=org.apache.tools.ant.util.ResourceUtils$1,outerType=None,innerName=None,accessFlags="static")
org/apache/tools/ant/util/ResourceUtils$1:
InnerClass(type=org.apache.tools.ant.util.ResourceUtils$1,outerType=None,innerName=None,accessFlags="static")
InnerClass(type=org.apache.tools.ant.util.ResourceUtils$2,outerType=None,innerName=None,accessFlags="")
InnerClass(type=org.apache.tools.ant.util.ResourceUtils$ResourceSelectorProvider,outerType=Some(org.apache.tools.ant.util.ResourceUtils),innerName=Some(ResourceSelectorProvider),accessFlags="public static [INTERFACE] abstract")
org/apache/tools/ant/util/ResourceUtils$2:
InnerClass(type=org.apache.tools.ant.util.ResourceUtils$1,outerType=None,innerName=None,accessFlags="static")
InnerClass(type=org.apache.tools.ant.util.ResourceUtils$2,outerType=None,innerName=None,accessFlags="")
org/apache/tools/ant/util/ResourceUtils$ResourceSelectorProvider:
InnerClass(type=org.apache.tools.ant.util.ResourceUtils$ResourceSelectorProvider,outerType=Some(org.apache.tools.ant.util.ResourceUtils),innerName=Some(ResourceSelectorProvider),accessFlags="public static [INTERFACE] abstract")
Simplified:
ResourceUtils:
ResourceUtils$ResourceSelectorProvider
ResourceUtils$1
ResourceUtils$1:
ResourceUtils$1
ResourceUtils$2
ResourceUtils$ResourceSelectorProvider
ResourceUtils$2:
ResourceUtils$1
ResourceUtils$2
ResourceUtils$ResourceSelectorProvider:
ResourceUtils$ResourceSelectorProvider
The problem seems to be that the two inner classes ResourceUtils$1
and ResourceUtils$2
are referencing each other in their inner classes attributes. After looking at the source code, apparently they were produced by a construct such as:
class Test {
Foo returnFoo() {
return new Foo() {
Bar returnBar() {
return new Bar() {
}
}
}
}
}
I could not reproduce that in a test case though, because it will produce Test$1
and Test$1$1
as opposed to Test$1
and Test$2
like in the attached class files. (Perhaps they were produced by an older Java compiler which behaved differently.)
Comments (20)
-
reporter -
reporter - attached ResourceUtils$2.class
- attached ResourceUtils$ResourceSelectorProvider.class
- attached ResourceUtils.class
- attached ResourceUtils$1.class
-
repo owner FYI
I can reproduce the error - I'll take a look into this issue!
-
repo owner After a very careful study it is obvious that this code violates the specification. (The class ResourceUtils$1 does not specify its outer class (it has no EnclosingMethod attribute)).
However, given that multiple projects fail, I'll look for a solution!
-
repo owner I implemented an approach that solves this (instance of?) problem. It will be available with the next commit.
Anyway, I would highly appreciate it, if you could tell me if also works for the other projects in the qualitas corpus.
-
repo owner - changed component to Bytecode Representation
-
assigned issue to
-
repo owner - changed status to resolved
fixes issue
#45→ <<cset 5a838f15fd27>>
-
reporter - changed status to open
The issue has been solved for a lot of the projects from the Qualitas Corpus, but not all. I'll attach a set of class files from the batik 1.7 project which still trigger the infinite recursion problem.
-
reporter - attached batik-1.7-classfiles.zip
-
repo owner - changed status to resolved
fixed issue
#45→ <<cset 53baf9c510b0>>
-
reporter Since the last change, there sometimes seems to be an infinite loop during
foreachNestedClasses
(although, no crash). I'll attach an affected set of class files. -
reporter - attached argouml-testcase.zip
-
reporter - changed status to open
-
repo owner I wonder, if this issue will ever be finally resolved...
(in this case the problem was a named inner class of an anonymous outer class, where the anonymous outer class did not give any information about the named inner class....)
-
repo owner - changed status to resolved
fixed issue
#45added another test case
Signed-off-by: Michael Eichberg mail@michael-eichberg.de
→ <<cset d308ca813b56>>
-
reporter - changed status to open
Another test case causing an infinite loop:
-
reporter - attached batik-testcase-2.zip
-
repo owner - changed status to resolved
fixed issue
#45→ <<cset 10e9811b7524>>
-
repo owner - removed milestone
Removing milestone: 0.8.0-M3 (automated comment)
-
repo owner - removed version
Removing version: 0.8.0 (automated comment)
- Log in to comment