Search code examples
gwt

Stack Overflow error (infinite loop ?) during GWT compilation


I've been doing mvn clean install on my GWT projet for months, and now it is broken. I get the following stack trace:

[INFO]    Compiling 3 permutations
[INFO]       Compiling permutation 1...
[INFO]       Process output
[INFO]          Compiling
[INFO]             Compiling permutation 0...
[INFO]       Process output
[INFO]          Compiling
[INFO]             Compiling permutation 2...
[INFO]       [ERROR] StackOverflowError: Increase stack size
[INFO] java.lang.StackOverflowError
[INFO]  at java.lang.StringBuffer.append(StringBuffer.java:322)
[INFO]  at java.io.StringWriter.write(StringWriter.java:94)
[INFO]  at java.io.PrintWriter.write(PrintWriter.java:426)
[INFO]  at java.io.PrintWriter.write(PrintWriter.java:443)
[INFO]  at java.io.PrintWriter.print(PrintWriter.java:587)
[INFO]  at com.google.gwt.dev.util.AbstractTextOutput.printAndCount(AbstractTextOutput.java:148)
[INFO]  at com.google.gwt.dev.util.AbstractTextOutput.print(AbstractTextOutput.java:107)
[INFO]  at com.google.gwt.dev.js.JsToStringGenerationVisitor._nameRef(JsToStringGenerationVisitor.java:1190)
[INFO]  at com.google.gwt.dev.js.JsToStringGenerationVisitor.visit(JsToStringGenerationVisitor.java:723)
[INFO]  at com.google.gwt.dev.js.ast.JsNameRef.traverse(JsNameRef.java:117)
[INFO]  at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:468)
[INFO]  at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:445)
[INFO]  at com.google.gwt.dev.js.JsSourceGenerationVisitorWithSizeBreakdown.generateAndBill(JsSourceGenerationVisitorWithSizeBreakdown.java:119)
[INFO]  at com.google.gwt.dev.js.JsReportGenerationVisitor.generateAndBill(JsReportGenerationVisitor.java:58)
[INFO]  at com.google.gwt.dev.js.JsSourceGenerationVisitorWithSizeBreakdown.doAccept(JsSourceGenerationVisitorWithSizeBreakdown.java:96)
[INFO]  at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
[INFO]  at com.google.gwt.dev.js.JsToStringGenerationVisitor.visit(JsToStringGenerationVisitor.java:672)
[INFO]  at com.google.gwt.dev.js.ast.JsInvocation.traverse(JsInvocation.java:69)
[INFO]  at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:468)
[INFO]  at com.google.gwt.dev.js.ast.JsVisitor.doAccept(JsVisitor.java:445)

As you can see I only have 3 permutations. The last lines of the output (the com.google.gwt.dev.js stuff) are repeated tens of times (I didn't paste everything) which make me think this might be related to some infinite loop.

After the stack overflow error is printed, I get the rest of the stack trace as follow:

[INFO]  at com.google.gwt.dev.js.ast.JsVisitor.accept(JsVisitor.java:109)
[INFO]  at com.google.gwt.dev.js.JsToStringGenerationVisitor.visit(JsToStringGenerationVisitor.java:325)
[INFO]  at com.google.gwt.dev.js.ast.JsBinaryOperation.traverse(JsBinaryOperation.java:112)
[INFO]  at com.google.gwt.dev.js.ast.JsVisitor.doTraverse(JsVisitor.java:468)
[INFO]          [ERROR] Stack overflow; to increase the stack size, use the -Xss flag at startup (java -Xss1M ...)
[INFO]       [ERROR] Unrecoverable exception, shutting down
[INFO] com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
[INFO]  at com.google.gwt.dev.ThreadedPermutationWorkerFactory$ThreadedPermutationWorker.compile(ThreadedPermutationWorkerFactory.java:60)
[INFO]  at com.google.gwt.dev.PermutationWorkerFactory$Manager$WorkerThread.run(PermutationWorkerFactory.java:73)
[INFO]  at java.lang.Thread.run(Thread.java:722)
[INFO]       [ERROR] Not all permutation were compiled , completed (0/3)
[INFO]       [WARN] Lost communication with remote process
[INFO] java.net.SocketException: socket closed
[INFO]  at java.net.SocketInputStream.socketRead0(Native Method)
[INFO]  at java.net.SocketInputStream.read(SocketInputStream.java:150)
[INFO]  at java.net.SocketInputStream.read(SocketInputStream.java:121)
[INFO]  at java.net.SocketInputStream.read(SocketInputStream.java:203)
[INFO]  at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2266)
[INFO]  at java.io.ObjectInputStream$BlockDataInputStream.peek(ObjectInputStream.java:2559)
[INFO]  at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2569)
[INFO]  at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1315)
[INFO]  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
[INFO]  at com.google.gwt.dev.ExternalPermutationWorkerFactory$ExternalPermutationWorker.compile(ExternalPermutationWorkerFactory.java:152)
[INFO]  at com.google.gwt.dev.PermutationWorkerFactory$Manager$WorkerThread.run(PermutationWorkerFactory.java:73)
[INFO]  at java.lang.Thread.run(Thread.java:722)
[INFO]       [WARN] Lost communication with remote process
[INFO] java.net.SocketException: socket closed
[INFO]  at java.net.SocketInputStream.socketRead0(Native Method)

Could anyone help me ?


Solution

  • We had to set higher values for the JVM arguments inside the GWT-Maven-Plugin configuration.

    <plugin>
         <groupId>org.codehaus.mojo</groupId>
          <artifactId>gwt-maven-plugin</artifactId>
          <version>${gwt-maven-plugin.version}</version>
          <executions>
              <execution>
                 <configuration>
                    <extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
                  </configuration>
    ...
    

    That's it.