Sonarscanner dreadfully slow scanning c++ source code

Template for a good new topic, formatted with Markdown:

  • CI system used (Bitbucket Cloud, Azure DevOps, Travis CI, Circle CI
    Manually running sonarscanner from command line for testing

  • Scanner command used when applicable (private details masked)
    sonar-scanner-4.7.0.2747-windows\bin\sonar-scanner.bat -X -Dsonar.login=xxxx

  • Languages of the repository
    C++

  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
    The scanner analysis of the c++ code is incredibly slow.

I don’t know where to start or what to include as information here.

The scanner will run and start producing tons of debug information as it goes through header files. The scanner will run and run for hours and will get to a point where it stops putting out any information. When I look at the task manager it shows threads are still active and consuming CPU but nothing seems to be getting done. I have left it scanning overnight and in the morning there is no additional log information that got produced. It is like the scanning threads are all hung up doing “something”. They are working because they are consuming CPU but I don’t know what is being “worked” on…

I have searched and searched for days trying to find some clue as to what might be happening but have gotten nowhere. I am at the point of abandoning the effort but thought I would cast a line out there and see if there is a clue from someone.

sonar-project.properties

sonar.organization=iman-dev
sonar.projectName=XXX
sonar.projectKey=XXX
sonar.host.url=https://sonarcloud.io
sonar.working.directory=target/sonar
sonar.cfamily.threads=3
sonar.cfamily.cache.enabled=true
sonar.cfamily.cache.path=sonar/sonar-cache/target/sonar-cache

#testing options
sonar.showProfiling=true
sonar.sourceEncoding=UTF-8

sonar.sources=app
sonar.inclusions=app/**/*.cpp
#sonar.inclusions=app/cpydms/**/AppProxy.cpp
sonar.exclusions=app/**/target/**/*,app/**/dftest/**/*,app/**/target_src/**/*

#original
#sonar.sources=mlib,app
#sonar.exclusions=app/**/tests/**,mlib/**/restclient-tests/**,mlib/**/restclient-mocks/**,mlib/**/DownloadTest/**,mlib/**/target/**,app/**/target/**


sonar.cfamily.build-wrapper-output=build_wrapper_output_directory

build wrapper version used on compile:
'build-wrapper, version 6.37 (win-x86-64)`

build-wrapper-win-x86-64.exe --out-dir build_wrapper_output_directory mvn.cmd -T 4 install -Pbuild-core

sonar-scanner version

INFO: Project root configuration file: C:\Users\XXX\gitRepo\work-server-core\sonar-project.properties
INFO: SonarScanner 4.7.0.2747
INFO: Java 11.0.14.1 Eclipse Adoptium (64-bit)
INFO: Windows 10 10.0 amd64
  • Steps to reproduce
  • Potential workaround

Hi @bapserver ,

thank you for the detailed explanation.

It may happen that the analyzer gets “stuck” on a given file. You could try to set sonar.cfamily.threads=1 and see on which compilation unit it gets stuck. Would you be able to do that?

Thanks for responding.

That is the direction I headed and I think I found a repeatable case but am still trying to narrow it down. Very convoluted code path getting into the boost libraries.

Hi @bapserver ,

if you manage to identify a compilation unit that explodes your analysis I am going to ask you to create a reproducer to allow us to reproduce it and find a solution.

I was able to find roughly 10 files that was causing the scanner to have an issue. Using exclusions I was able to remove them from the scan and the scan finishes.

I will investigate if I can find a small reproducible test but I don’t have much confidence in my ability to do that.

Hi @bapserver ,

you don’t need to reduce the test. If you have identified one compilation unit it is enough to create a reproducer. I am going to write you a private message with instructions to generate it and share it with me.

Hi @bapserver ,

thank you for providing the reproducer, I managed to reproduce it. I created a ticket [CPP-3900] - Jira. It should get fixed in the next version.

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