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

**URL:** <https://community.sonarsource.com/t/java-lang-stackoverflowerror-when-running-sonarcloud-orb-on-circleci-docker-base-image/42872>\
**Category:** SonarQube Cloud\
**Tags:** circleci, swift, sonarqube-cloud\
**Created:** [May 6, 2021, 12:34pm UTC](https://community.sonarsource.com/t/java-lang-stackoverflowerror-when-running-sonarcloud-orb-on-circleci-docker-base-image/42872 "2021-05-06T12:34:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![henrikforsberg](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/henrikforsberg/32/21953_2.png) [@henrikforsberg](https://community.sonarsource.com/u/henrikforsberg)\
**Post date:** [May 6, 2021, 12:34pm UTC](https://community.sonarsource.com/t/java-lang-stackoverflowerror-when-running-sonarcloud-orb-on-circleci-docker-base-image/42872/1 "2021-05-06T12:34:42Z")

</div>

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](https://circleci.com/docs/2.0/circleci-images/#circleci-base-image)

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

```auto
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** ):

```auto
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.

---

<div class="post-metadata">

**Author:** ![mickaelcaro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mickaelcaro/32/4147_2.png) [@mickaelcaro](https://community.sonarsource.com/u/mickaelcaro)\
**Post date:** [May 7, 2021, 7:58am UTC](https://community.sonarsource.com/t/java-lang-stackoverflowerror-when-running-sonarcloud-orb-on-circleci-docker-base-image/42872/2 "2021-05-07T07:58:32Z")

</div>

Hi @henrikforsberg

Seeing the

```auto
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

---

<div class="post-metadata">

**Author:** ![henrikforsberg](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/henrikforsberg/32/21953_2.png) [@henrikforsberg](https://community.sonarsource.com/u/henrikforsberg)\
**Post date:** [May 7, 2021, 11:56am UTC](https://community.sonarsource.com/t/java-lang-stackoverflowerror-when-running-sonarcloud-orb-on-circleci-docker-base-image/42872/3 "2021-05-07T11:56:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mickaelcaro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mickaelcaro/32/4147_2.png) [@mickaelcaro](https://community.sonarsource.com/u/mickaelcaro)\
**Post date:** [May 7, 2021, 12:29pm UTC](https://community.sonarsource.com/t/java-lang-stackoverflowerror-when-running-sonarcloud-orb-on-circleci-docker-base-image/42872/4 "2021-05-07T12:29:14Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![henrikforsberg](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/henrikforsberg/32/21953_2.png) [@henrikforsberg](https://community.sonarsource.com/u/henrikforsberg)\
**Post date:** [May 7, 2021, 12:51pm UTC](https://community.sonarsource.com/t/java-lang-stackoverflowerror-when-running-sonarcloud-orb-on-circleci-docker-base-image/42872/5 "2021-05-07T12:51:09Z")

</div>

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

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![henrikforsberg](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/henrikforsberg/32/21953_2.png) [@henrikforsberg](https://community.sonarsource.com/u/henrikforsberg)\
**Post date:** [May 10, 2021, 2:40pm UTC](https://community.sonarsource.com/t/java-lang-stackoverflowerror-when-running-sonarcloud-orb-on-circleci-docker-base-image/42872/6 "2021-05-10T14:40:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [May 17, 2021, 2:40pm UTC](https://community.sonarsource.com/t/java-lang-stackoverflowerror-when-running-sonarcloud-orb-on-circleci-docker-base-image/42872/7 "2021-05-17T14:40:52Z")

</div>

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