title: java.lang.StackOverflowError when parsing Groovy script on Jenkins
body: <p>We are experiencing a problem with our Jenkins CI server.  </p>
  
  <p>Our CI implementation relies on several Groovy scripts, which we execute in Jenkins as "System Groovy scripts".  This has been this way for years, and the scripts have undergone no recent modifications, and implement build flows, business logic steps such as version checking, etc.</p>
  
  <p>Yesterday we started experiencing an exception in every Jenkins job that we tried to lauch that, one way or another, tried to execute Groovy scripts.  The exception is:</p>
  
  <pre><code>java.lang.StackOverflowError
  at org.codehaus.groovy.antlr.parser.GroovyRecognizer.additiveExpression(GroovyRecognizer.java:12478)
  at org.codehaus.groovy.antlr.parser.GroovyRecognizer.shiftExpression(GroovyRecognizer.java:9695)
  at org.codehaus.groovy.antlr.parser.GroovyRecognizer.relationalExpression(GroovyRecognizer.java:12383)
  at org.codehaus.groovy.antlr.parser.GroovyRecognizer.equalityExpression(GroovyRecognizer.java:12307)
  at org.codehaus.groovy.antlr.parser.GroovyRecognizer.regexExpression(GroovyRecognizer.java:12255)
  at org.codehaus.groovy.antlr.parser.GroovyRecognizer.andExpression(GroovyRecognizer.java:12223)
  at org.codehaus.groovy.antlr.parser.GroovyRecognizer.exclusiveOrExpression(GroovyRecognizer.java:12191)
              hundreds of similar lines
  at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compoundStatement(GroovyRecognizer.java:7510)
  at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compatibleBodyStatement(GroovyRecognizer.java:8834)
  at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:899)
  at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:757)
  at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:131)
  at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:108)
  at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:236)
  at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:161)
  at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:846)
  at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:550)
  at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:526)
  at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:503)
  at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:302)
  at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:281)
  at groovy.lang.GroovyShell.parseClass(GroovyShell.java:731)
  at groovy.lang.GroovyShell.parse(GroovyShell.java:743)
  at groovy.lang.GroovyShell.parse(GroovyShell.java:770)
  at groovy.lang.GroovyShell.parse(GroovyShell.java:761)
  at groovy.lang.GroovyShell$parse.call(Unknown Source)
  at com.cloudbees.plugins.flow.FlowDSL.executeFlowScript(FlowDSL.groovy:80)
  at com.cloudbees.plugins.flow.FlowRun$FlyweightTaskRunnerImpl.run(FlowRun.java:219)
  at hudson.model.Run.execute(Run.java:1759)
  at com.cloudbees.plugins.flow.FlowRun.run(FlowRun.java:155)
  at hudson.model.ResourceController.execute(ResourceController.java:89)
  at hudson.model.Executor.run(Executor.java:240)
  at hudson.model.OneOffExecutor.run(OneOffExecutor.java:43)
  </code></pre>
  
  <p>This looks like that the Groovy parser inside Jenkins is reaching the top of the stack while trying to parse the groovy script (as I have said, this abruptly started to happen with many scripts that worked perfectly before and had undergone no recent modification).  </p>
  
  <p>Currently our Jenkins installation (v1.594) runs on a Websphere 8.5.5.2 application server on AIX v7.1 (don't know exactly the fix pack level and / or if it has recently suffered any kind of update, still trying to gather the info).  </p>
  
  <p>After a restart, we returned to normal behavior (all the scripts were working as usual again without any modification to them).</p>
  
  <p>Does anyone know about some incompatibility of any underlying library with Jenkins Groovy parsing?  </p>