java.lang.StackOverflowError when running SonarCloud orb on CircleCI Docker base image

We are trying to set up SonarCloud with CircleCI for one of our iOS projects on a GitHub repository, but encountering some hard-to-resolve errors.

These are the steps we have taken so far:

  • Since we are using CircleCI, naturally we chose to follow the instructions for analyzing with CircleCI.
  • We have created a SonarCloud context and added a SONAR_TOKEN environment variable.
  • Since our project is in Swift, we selected “Other” to best describe our build.
  • We have allowed our organization to use third-party orbs.
  • Since the orb doesn’t support macOS, we chose to use the pre-built CircleCI base image

Here is what was added to our existing .circleci/config.yml (stripped out our other jobs):

version: 2.1
orbs:
  sonarcloud: sonarsource/sonarcloud@1.0.2

jobs:
  sonar-cloud-orb:
    docker:
      - image: cimg/base:2021.04
    steps:
      - checkout
      - sonarcloud/scan

workflows:
  version: 2
  build-and-deploy:
    jobs:
      - sonar-cloud-orb:
          context: SonarCloud
          filters:
            branches:
              only: develop

And when we push to develop branch we get the following error message (stripped out most of the stacktrace to keep within character limits):

INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 47.388s
INFO: Final Memory: 55M/194M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
java.lang.StackOverflowError
	at java.base/java.util.stream.AbstractPipeline.wrapSink(Unknown Source)
    [ ... ]
	at java.base/java.util.Spliterators$IteratorSpliterator.tryAdvance(Unknown Source)
ERROR: 
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.

Exited with code exit status 1
CircleCI received exit code 1

Which doesn’t say that much to us what went wrong.
Not sure how to use the -X switch when using the orb but we did also try to manually download and run sonar-scanner on the Linux image just so we could add the -X switch and get verbose logging. Alas, the same error was thrown without any useful logs or hints as to what is going on.

Any help with moving forward on this would be very appreciated as we are currently at a loss on how to fix it. Please let me know if any more information is needed to be able to investigate this.

Hi @henrikforsberg

Seeing the

INFO: Final Memory: 55M/194M

It looks like the JVM runing the scan doesn’t have that much of memory available. Can you try to increase the heap size ?

Mickaël

Unfortunately I have no idea how to do that but I definitely want to give it a try. Could you please give me a hint on how to proceed?

I’m not quite sure of the outcome, but maybe try this :

jobs:
  sonar-cloud-orb:
    docker:
      - image: cimg/base:2021.04
    environment:
       SONAR_SCANNER_OPTS: -Xmx512m
    steps:
      - checkout
      - sonarcloud/scan

1 Like

I immediately tried it. Sadly, that gave us basically the same output as before:

INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 40.500s
INFO: Final Memory: 55M/194M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
java.lang.StackOverflowError
	at java.base/java.util.stream.StreamOpFlag.fromCharacteristics(Unknown Source)

For @mickaelcaro and anyone else seeing this: We realized this was actually a stackoverflow error so we ended up adding the following to the environment to increase the stack size: SONAR_SCANNER_OPTS: -Xss16m -Xmx1g
Seems to have done the trick.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.