We have been using SonarCloud for a while now. On June 30, our sonar build started failing in our main branch. It’s working fine when run as apart of a pull request, but in our main branch it fails due to a StackOverflowError
. The odd thing is that this started happening on a scheduled job, meaning there were no code differences in our repository between the last known good run and the first failed run. It has failed consistently ever since. I’ve also been able to reproduce it running sonar locally, and it fails even when checked out to a version of the code that succeeded in Github Actions.
Here is the command we’re using.
mvn clean compile -DskipTests org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
--show-version \
--errors \
--batch-mode \
--file ./pom.xml \
-T 2C \
-Dsonar.verbose=true \
-X \
-Dsonar.projectKey=**** \
-Dsonar.qualitygate.wait=true \
-Dsonar.qualitygate.timeout=900
I noticed Maven warning about the sonar plugin not supporting parallelism, but it failed even after removing -T 2C
from the command.
Here’s our maven/java version (unchanged between the good and bad run). I tried Amazon Corretto’s 21.0.7 just in case, and it failed also.
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /opt/maven
Java version: 21.0.7, vendor: Eclipse Adoptium, runtime: /opt/actions-runner/_work/_tool/Java_Temurin-Hotspot_jdk/21.0.7-6.0.LTS/x64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "6.8.0-1029-aws", arch: "amd64", family: "unix"
I’ve tried increasing the stack size by setting SONAR_SCANNER_JAVA_OPTS
to -Xss16m -XX:MaxRAMPercentage=80
and no luck. I can tell that I’m setting it properly because I see this in my logs (if I enable debug logs):
Executing: /home/runner/.sonar/cache/bcb1b7b8ad68c93093f09b591b7cb17161d39891f7d29d33a586f5a328603707/OpenJDK17U-jre_x64_linux_hotspot_17.0.11_9.tar.gz_extracted/jdk-17.0.11+9-jre/bin/java -Xss16m -XX:MaxRAMPercentage=80 -Dorg.bouncycastle.pkcs12.ignore_useless_passwd=true -jar /home/runner/.sonar/cache/8c20c2157519bcc7897e99dc64276ea1c23c27d5b41dbbd620991f5faaa46714/sonarcloud-scanner-engine-11.12.0.497.jar
Just in case, I tried setting it to 512m
and it still ran into the error.
We are not hardcoding a version in our pom file, but I see the same sonar scanner version in the maven logs in both the successful and failed build:
--- sonar:5.1.0.4751:sonar (default-cli) @ <Project> ---
Here is a subset of the stacktrace:
[DEBUG] Skipping method validateConcurrentCallSettings as it uses a not-yet-supported language feature: TryStatementTreeImpl
[DEBUG] Could not write DBD Java frontend version to cache (key 'javabugs:dataVersion', value '2.1.0.16377')
[INFO] Did not optimize analysis for any files, performed a full analysis for all 1295 files.
[DEBUG] Closing monitoring resources of Helm evaluator
[ERROR] Error during SonarScanner Engine execution
java.lang.StackOverflowError: null
at org.eclipse.jdt.internal.compiler.lookup.Scope$Substitutor.substitute(Scope.java:589)
at org.eclipse.jdt.internal.compiler.lookup.Scope$Substitutor.substitute(Scope.java:731)
at org.eclipse.jdt.internal.compiler.lookup.Scope$Substitutor.substitute(Scope.java:610)
at org.eclipse.jdt.internal.compiler.lookup.Scope$Substitutor.substitute(Scope.java:632)
at org.eclipse.jdt.internal.compiler.lookup.Scope$Substitutor.substitute(Scope.java:731)
at org.eclipse.jdt.internal.compiler.lookup.Scope$Substitutor.substitute(Scope.java:610)
at org.eclipse.jdt.internal.compiler.lookup.Scope.substitute(Scope.java:536)
at org.eclipse.jdt.internal.compiler.lookup.CaptureBinding.initializeBounds(CaptureBinding.java:207)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.capture(ParameterizedTypeBinding.java:222)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.capture(ParameterizedTypeBinding.java:1)
at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.maybeCapture(InferenceContext18.java:2218)
at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isSuperclassOf(ReferenceBinding.java:1719)
at org.eclipse.jdt.internal.compiler.lookup.CaptureBinding.initializeBounds(CaptureBinding.java:244)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.capture(ParameterizedTypeBinding.java:222)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.capture(ParameterizedTypeBinding.java:1)
at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.maybeCapture(InferenceContext18.java:2218)
at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isSuperclassOf(ReferenceBinding.java:1719)
at org.eclipse.jdt.internal.compiler.lookup.CaptureBinding.initializeBounds(CaptureBinding.java:244)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.capture(ParameterizedTypeBinding.java:222)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.capture(ParameterizedTypeBinding.java:1)
at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.maybeCapture(InferenceContext18.java:2218)
at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isSuperclassOf(ReferenceBinding.java:1719)
at org.eclipse.jdt.internal.compiler.lookup.CaptureBinding.initializeBounds(CaptureBinding.java:244)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.capture(ParameterizedTypeBinding.java:222)
at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.capture(ParameterizedTypeBinding.java:1)
at org.eclipse.jdt.internal.compiler.lookup.InferenceContext18.maybeCapture(InferenceContext18.java:2218)
at org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding.isSuperclassOf(ReferenceBinding.java:1719)
I have not yet been able to find a workaround (besides deleting all the java files in the project) or a way to reproduce this with a sample project.