JDK-6326330 : Out of memory and high CPU when compiling a JSP
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.4.2,1.4.2_04
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_9,windows_xp
  • CPU: other,sparc
  • Submitted: 2005-09-20
  • Updated: 2011-12-27
  • Resolved: 2006-06-03
Related Reports
Duplicate :  
Duplicate :  
Description
JDK version(s)
 
Problem details :
When compiling a JSP, CPU goes high and an Out of Memory error is seen.  Heap shows    
many "com/sun/tools/javac v8/com/Resolve$AmbiguityError" objects.
There also is indication of a loop.
Customer can exhibit this problem in a simple standalone testcase below :
import java.io.*;
public class Test                                                       
{                                                                       
public static void main(String args[])                                  
{                                                                       
String s1=t1+t2;                                                        
}                                                                       
}
On compilation on 1.4.2 this simple java testcase produces 100% CPU usage. But the same would not lead to 100% CPU if replaced with tools.jar of JDK 1.4.1. 
----------------------------------------------------------------------------------------------------------
here is the output with original 142 tools.jar
C:\work\pmrs\11125>javac test.java
test.java:7: cannot resolve symbol
symbol  : variable t1
location: class Test
String s1=t1+t2;
          ^
test.java:7: cannot resolve symbol
symbol  : variable t2
location: class Test
String s1=t1+t2;
             ^
The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError
----------------------------------------------------------------------------------------------------------
here is the output after replacing 142 tools.jar with 1.4.1 tools.jar
C:\work\pmrs\11125>javac test.java
test.java:7: cannot resolve symbol
symbol  : variable t1
location: class Test
String s1=t1+t2;
          ^
test.java:7: cannot resolve symbol
symbol  : variable t2
location: class Test
String s1=t1+t2;
             ^
2 errors
Note: Introducing a "" in between these 2  variables solves the problem of 100% CPU, something like this. String s1=t1+""+t2;

Comments
SUGGESTED FIX This is untested but the problem goes away: Index: generics/src/share/javac/com/sun/tools/javac/v8/comp/Resolve.java --- /tmp/geta16425 2006-06-03 03:47:47.000000000 -0700 +++ Resolve.java 2006-06-03 03:45:54.000000000 -0700 @@ -446,7 +446,12 @@ Symbol err2 = mostSpecific(m1, e.sym2, env, site); if (err1 == err2) return err1; if (err1 == e.sym1 && err2 == e.sym2) return m2; - return new AmbiguityError(err1, err2); + if (err1 instanceof AmbiguityError && + err2 instanceof AmbiguityError && + ((AmbiguityError)err1).sym1 == ((AmbiguityError)err2).sym1) + return new AmbiguityError(m1, m2); + else + return new AmbiguityError(err1, err2); default: throw new AssertionError(); }
03-06-2006

EVALUATION $ /usr/java/jdk1.6.0/bin/javac -J-showversion Test.java java version "1.6.0-ea" Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b52) Java HotSpot(TM) Client VM (build 1.6.0-ea-b52, mixed mode, sharing) Test.java:6: cannot find symbol symbol : variable t1 location: class Test String s1=t1+t2; ^ Test.java:6: cannot find symbol symbol : variable t2 location: class Test String s1=t1+t2; ^ 2 errors
20-09-2005