Exception in thread "main" java.lang.StackOverflowError

summary
SonarScanner CLI ends up with Exception in thread "main" java.lang.StackOverflowError when scanning a python file.

which versions are you using

  • SonarQube Server Enterprise Edition 10.8.1.101195
  • SonarScanner CLI 7.0.2.4839

how is SonarQube deployed

  • kubernetes/docker

what are you trying to achieve

  • scan a python file

what have you tried so far to achieve this

  • setup works with different python files than the one mentioned below (and other languages)

How to reproduce:
Scan a file test.py with the following content:

def _update_transfer(xfr, job):
    job_status = job['status']
    if xfr.pcs_status == job_status:
        return
    xfr.pcs_status = job_status
    if job_status in ('NEW', 'REQUESTED', 'RUNNING'):
        xfr.status = 'RUNNING'
    elif job_status not in ('FINISHED', 'CANCELED', 'FAILED', 'EXPIRED'):
        xfr.status = 'UNKNOWN'
    else:
        xfr.finished_at = _to_datetime('changeTimestamp')
        if job_status == 'FINISHED':
            xfr.status = 'SUCCESS'
            xfr.pcs_message = (job.get('warningMessage') or '').strip()[:10000] or None
        else:
            xfr.status = 'CANCELED' if job_status == 'CANCELED' else 'FAILED'
            xfr.pcs_message = (job.get('errorMessage') or '').strip()[:10000] or None
    xfr.save()

Result

$ sonar-scanner -D"sonar.host.url=${SONAR_URL}" -D"sonar.login=${SONAR_TOKEN}"
16:20:21.728 INFO  Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
16:20:21.731 INFO  Project root configuration file: [redacted]/sonar-project.properties
16:20:21.741 INFO  SonarScanner CLI 7.0.2.4839
16:20:21.742 INFO  Java 17.0.13 Ubuntu (64-bit)
16:20:21.743 INFO  Linux 5.4.0-204-generic amd64
16:20:21.763 WARN  Both 'sonar.login' and 'sonar.token' (or the 'SONAR_TOKEN' env variable) are set, but only the latter will be used.
16:20:21.766 INFO  User cache: /root/.sonar/cache
16:20:22.696 WARN  Use of 'sonar.login' property has been deprecated in favor of 'sonar.token' (or the env variable alternative 'SONAR_TOKEN'). Please use the latter when passing a token.
16:20:22.696 INFO  JRE provisioning: os[linux], arch[x86_64]
16:20:25.509 INFO  Communicating with SonarQube Server 10.8.1.101195
16:20:25.714 INFO  Starting SonarScanner Engine...
16:20:25.715 INFO  Java 17.0.11 Eclipse Adoptium (64-bit)
16:20:26.449 INFO  Load global settings
16:20:26.792 INFO  Load global settings (done) | time=343ms
16:20:26.803 INFO  Server id: [redacted]
16:20:26.813 INFO  Loading required plugins
16:20:26.814 INFO  Load plugins index
16:20:26.857 INFO  Load plugins index (done) | time=43ms
16:20:26.857 INFO  Load/download plugins
16:20:29.839 INFO  Load/download plugins (done) | time=2983ms
16:20:30.057 INFO  Loaded core extensions: developer-scanner, sca, server-common
16:20:30.251 INFO  Process project properties
16:20:30.251 INFO  Process project properties (done) | time=0ms
16:20:30.255 INFO  Project key: [redacted]
16:20:30.256 INFO  Base dir: [redacted]
16:20:30.256 INFO  Working dir: [redacted]/.scannerwork
16:20:30.259 INFO  Load project settings for component key: '[redacted]'
16:20:30.338 INFO  Load project settings for component key: '[redacted]' (done) | time=78ms
16:20:30.353 INFO  Load project branches
16:20:30.394 INFO  Load project branches (done) | time=41ms
16:20:30.395 INFO  Load branch configuration
16:20:30.395 INFO  Detected branch/PR in 'GitLab'
16:20:30.396 INFO  Auto-configuring branch 'main'
16:20:30.397 INFO  Load branch configuration (done) | time=2ms
16:20:30.405 INFO  Load quality profiles
16:20:30.480 INFO  Load quality profiles (done) | time=74ms
16:20:30.484 INFO  Auto-configuring with CI 'Gitlab CI'
16:20:30.527 WARN  SCM-TFVC: Missing configuration for CollectionUri. The project may not receive blame information.
16:20:30.540 INFO  Load active rules
16:20:33.763 INFO  Load active rules (done) | time=3222ms
16:20:33.767 INFO  Load analysis cache
16:20:33.797 INFO  Load analysis cache (404) | time=29ms
16:20:33.853 INFO  Branch name: main
16:20:33.854 WARN  The property 'sonar.login' is deprecated and will be removed in the future. Please use the 'sonar.token' property instead when passing a token.
16:20:33.863 INFO  Preprocessing files...
16:20:33.918 INFO  1 language detected in 3 preprocessed files
16:20:33.918 INFO  0 files ignored because of scm ignore settings
16:20:33.919 INFO  Loading plugins for detected languages
16:20:33.919 INFO  Load/download plugins
16:20:37.703 INFO  Load/download plugins (done) | time=3784ms
16:20:37.784 INFO  Load project repositories
16:20:37.803 INFO  Load project repositories (done) | time=20ms
16:20:37.811 INFO  Indexing files...
16:20:37.812 INFO  Project configuration:
16:20:37.819 INFO  3 files indexed
16:20:37.820 INFO  Quality profile for py: Sonar way
16:20:37.820 INFO  ------------- Run sensors on module [redacted]
16:20:37.860 INFO  Load metrics repository
16:20:37.873 INFO  Load metrics repository (done) | time=13ms
16:20:38.372 INFO  Sensor Python Sensor [python]
16:20:38.382 INFO  Starting global symbols computation
16:20:38.385 INFO  1 source file to be analyzed
16:20:38.624 INFO  1/1 source file has been analyzed
16:20:38.637 INFO  Starting rules execution
16:20:38.637 INFO  1 source file to be analyzed
16:20:39.144 ERROR [stderr] Exception in thread "main" java.lang.StackOverflowError
16:20:39.145 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.B(na:2262)
16:20:39.145 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.A(na:2385)
16:20:39.145 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.B(na:2599)
16:20:39.145 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.A(na:2839)
16:20:39.145 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.B(na:2599)
16:20:39.145 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.A(na:2839)
16:20:39.145 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.B(na:2599)
16:20:39.145 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.A(na:2839)
16:20:39.145 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.B(na:2599)
[...]
16:20:39.486 INFO  EXECUTION FAILURE
16:20:39.487 INFO  Total time: 17.760s

Maybe this is related to #131311. However, we are not using cloud, but server edition.

Hey @stmllr !

Thanks for the report. I tried analyzing your file against SonarQube v2025.1 LTA and it analyzed successfully. You should upgrade!

Thanks for your reply. I upgraded the Server to sonarqube:2025.1.0-enterprise and still end up with exceptions:

$ sonar-scanner -D"sonar.host.url=${SONAR_URL}" -D"sonar.login=${SONAR_TOKEN}"
22:13:25.147 INFO  Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
22:13:25.151 INFO  Project root configuration file: [redacted]/project.properties
22:13:25.161 INFO  SonarScanner CLI 7.0.2.4839
22:13:25.166 INFO  Java 17.0.13 Ubuntu (64-bit)
22:13:25.167 INFO  Linux 5.4.0-204-generic amd64
22:13:25.189 WARN  Both 'sonar.login' and 'sonar.token' (or the 'SONAR_TOKEN' env variable) are set, but only the latter will be used.
22:13:25.192 INFO  User cache: /root/.sonar/cache
22:13:25.980 WARN  Use of 'sonar.login' property has been deprecated in favor of 'sonar.token' (or the env variable alternative 'SONAR_TOKEN'). Please use the latter when passing a token.
22:13:25.980 INFO  JRE provisioning: os[linux], arch[x86_64]
22:13:28.887 INFO  Communicating with SonarQube Server 2025.1.0.102418
22:13:29.077 INFO  Starting SonarScanner Engine...
22:13:29.078 INFO  Java 17.0.13 Eclipse Adoptium (64-bit)
22:13:29.749 INFO  Load global settings
22:13:30.232 INFO  Load global settings (done) | time=483ms
22:13:30.240 INFO  Server id: [redacted]
22:13:30.248 INFO  Loading required plugins
22:13:30.248 INFO  Load plugins index
22:13:30.311 INFO  Load plugins index (done) | time=62ms
22:13:30.311 INFO  Load/download plugins
22:13:37.262 INFO  Load/download plugins (done) | time=6952ms
22:13:37.587 INFO  Loaded core extensions: developer-scanner, sca, server-common
22:13:37.810 INFO  Process project properties
22:13:37.810 INFO  Process project properties (done) | time=0ms
22:13:37.815 INFO  Project key: [redacted]
22:13:37.815 INFO  Base dir: [redacted]
22:13:37.816 INFO  Working dir: [redacted]/.scannerwork
22:13:37.819 INFO  Load project settings for component key: '[redacted]'
22:13:37.879 INFO  Load project settings for component key: '[redacted]' (done) | time=59ms
22:13:37.896 INFO  Load project branches
22:13:37.932 INFO  Load project branches (done) | time=36ms
22:13:37.933 INFO  Load branch configuration
22:13:37.934 INFO  Detected branch/PR in 'GitLab'
22:13:37.934 INFO  Auto-configuring branch 'main'
22:13:37.934 INFO  Load branch configuration (done) | time=2ms
22:13:37.945 INFO  Load quality profiles
22:13:38.103 INFO  Load quality profiles (done) | time=159ms
22:13:38.109 INFO  Auto-configuring with CI 'Gitlab CI'
22:13:38.154 WARN  SCM-TFVC: Missing configuration for CollectionUri. The project may not receive blame information.
22:13:38.168 INFO  Load active rules
22:13:38.519 INFO  Load active rules (done) | time=351ms
22:13:38.523 INFO  Load analysis cache
22:13:38.551 INFO  Load analysis cache (404) | time=28ms
22:13:38.615 INFO  Branch name: main
22:13:38.616 WARN  The property 'sonar.login' is deprecated and will be removed in the future. Please use the 'sonar.token' property instead when passing a token.
22:13:38.627 INFO  Preprocessing files...
22:13:38.677 INFO  1 language detected in 3 preprocessed files
22:13:38.677 INFO  0 files ignored because of scm ignore settings
22:13:38.678 INFO  Loading plugins for detected languages
22:13:38.678 INFO  Load/download plugins
22:13:41.130 INFO  Load/download plugins (done) | time=2451ms
22:13:41.216 INFO  Load project repositories
22:13:41.267 INFO  Load project repositories (done) | time=51ms
22:13:41.274 INFO  Indexing files...
2
22:13:41.281 INFO  3 files indexed
22:13:41.282 INFO  Quality profile for py: Sonar way
22:13:41.282 INFO  ------------- Run sensors on module [redacted]
22:13:41.335 INFO  Load metrics repository
2
2:13:41.370 INFO  Load metrics repository (done) | time=35ms
22:13:41.831 INFO  Sensor Python Sensor [python]
22:13:41.853 INFO  Starting global symbols computation
22:13:41.856 INFO  1 source file to be analyzed
22:13:42.031 INFO  1/1 source file has been analyzed
22:13:42.073 INFO  Starting rules execution
22:13:42.073 INFO  1 source file to be analyzed
22:13:42.592 ERROR [stderr] Exception in thread "main" java.lang.StackOverflowError
22:13:42.592 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.B(na:2262)
22:13:42.593 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.A(na:2385)
22:13:42.593 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.B(na:2599)
22:13:42.593 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.A(na:2839)
22:13:42.593 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.B(na:2599)
22:13:42.593 ERROR [stderr] 	at com.sonarsource.dbd.A.A.H.A(na:2839)
...
22:13:42.931 INFO  EXECUTION FAILURE
22:13:42.932 INFO  Total time: 17.787s

Thanks. I’ll flag this for our devs who maybe see something I don’t!

1 Like

Thank you for the report and the self-contained reproducer.

We have reproduced this bug internally and are fixing it. In the meantime, you can avoid a crash by excluding the file from analysis: Narrowing the focus of your analysis | SonarQube Server Documentation

Cheers,

Thanks Solal for taking care. Looking forward to a bugfix. We have already excluded the file temporarily from analysis.