Sonar analysis exception on a specific C++ file

I analysis fails with one of our specific c++ files. Here are the details of the sonarqube command:
/opt/sonarqube/bin/sonar-scanner -Dsonar.host.url=https://sonar.cd.sac.int.threatmetrix.com -Dsonar.projectKey=otin.pe -Dsonar.cpd.exclusions="/*" -Dsonar.projectBaseDir=/opt/work/otin -Dsonar.sources=/opt/work/otin -Dsonar.cfamily.build-wrapper-output=/opt/work/otin/cmakebuild/gcc8dbg/sonarqubeOtin -Dsonar.cfamily.threads=16 -Dsonar.exclusions="/3rdParty/, /3rdPartyInstall/, 3rdPartyPackage, /idev_tests/, /UnitTest/, /UnitTests/, /test/, /tests/, /Test/, /Tests/" -Dsonar.inclusions="/.c,**/.cpp,/*.h,/*.hpp" -Dsonar.projectVersion=99.0.0-1 -Dsonar.branch.name=OTIN-9864-integration-tests-should-run-using-minimal-docker-container-on-idev -Dsonar.cfamily.cache.enabled=true -Dsonar.cfamily.cache.path=/tmp/.sonar/otin -Dsonar.sourceEncoding=“UTF-8” || true
INFO: Scanner configuration file: /opt/sonarqube/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.3.0.2102
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Linux 4.19.76-linuxkit amd64
INFO: User cache: /root/.sonar/cache
INFO: Analyzing on SonarQube server 8.0.0
INFO: Default locale: “en_US”, source code encoding: “UTF-8”
INFO: User cache: /root/.sonar/cache
INFO: SonarCFamily plugin version: 6.7.0.15300

The exception is:
ERROR: Exception in thread pool-3-thread-10

com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: /opt/work/otin/Products/OTIN/Common/CustomerDataInfoCache.cpp

at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:76)

at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:73)

at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:33)

at com.sonar.cpp.plugin.CFamilySensor.lambda$process$5(CFamilySensor.java:500)

at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:53)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

INFO: ------------------------------------------------------------------------

INFO: EXECUTION FAILURE

INFO: ------------------------------------------------------------------------

INFO: Total time: 1:39.908s

INFO: Final Memory: 22M/94M

INFO: ------------------------------------------------------------------------

ERROR: Error during SonarScanner execution

java.lang.IllegalStateException: com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: /opt/work/otin/Products/OTIN/Common/CustomerDataInfoCache.cpp

at com.sonar.cpp.analyzer.AnalysisExecutor.submit(AnalysisExecutor.java:47)

at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:497)

at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:440)

at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:277)

at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)

at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)

at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:62)

at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)

at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)

at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)

at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:387)

at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:383)

at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:346)

at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)

at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)

at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)

at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)

at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)

at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)

at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)

at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.base/java.lang.reflect.Method.invoke(Unknown Source)

at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)

at com.sun.proxy.$Proxy0.execute(Unknown Source)

at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)

at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)

at org.sonarsource.scanner.cli.Main.execute(Main.java:112)

at org.sonarsource.scanner.cli.Main.execute(Main.java:75)

at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Caused by: com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: /opt/work/otin/Products/OTIN/Common/CustomerDataInfoCache.cpp

at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:76)

at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:73)

at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:33)

at com.sonar.cpp.plugin.CFamilySensor.lambda$process$5(CFamilySensor.java:500)

at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:53)

at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.base/java.lang.Thread.run(Unknown Source)

ERROR:

ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

Hello @Kamal_Chandra,
This error should generate sonar-cfamily.reproducer file in your directory that will help me debug the issue. Can you please share the file? let me know if you prefer to share it privately.

Hi Abbas,

Yes I have the file. How can I share it privately?

Kamal

Hello @Kamal_Chandra,

Thanks for your valuable report.
I was able to reproduce the crash. Ticket is created. Until the issue is fixed please exclude the crashing file from analysis to unblock it.

Thanks Abbas, we are still blocked by the other issue with corruption of cache? Can you tell me the status of this issue please?

ERROR: Error during SonarScanner execution
java.lang.IllegalArgumentException: 49 is not a valid line for pointer. File CommonComponents/PropertyBucket/stdafx.h has 23 line(s)
at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
at org.sonar.api.batch.fs.internal.DefaultInputFile.checkValid(DefaultInputFile.java:336)
at org.sonar.api.batch.fs.internal.DefaultInputFile.newPointer(DefaultInputFile.java:272)
at org.sonar.api.batch.fs.internal.DefaultInputFile.selectLine(DefaultInputFile.java:295)

Hello @Kamal_Chandra,

java.lang.IllegalArgumentException: 49 is not a valid line for pointer.

Cfamily 6.8 is available in the marketplace. It fixes this bug.

Thanks,

Hi @Abbas_Sabra, we have updated the CFamily plugin to v6.8.0.16475. Is this issue fixed by only this plugin or do we need build wrapper, sonar scanner updates etc?? My server is at v8.0.0, sonar-scanner is at v4.3.0.2102 and build wrapper at v6.7 and I still get this issue.

Hello @Kamal_Chandra,

  • We are talking here about the cache problem, right?

  • You should always update the build-wrapper with the plugin.

  • Clean the cache once after the update just to make sure that the issue can be reproduced from the scratch.

  • If the cache issue is still happening, please follow-up (sharing the stack trace) on your initial cache-related post just to avoid mixing topics.

Thanks,

Sorry yes it is the cache issue. I did update the builder and cleaned the cache. I will post a stack trace on the original post. Thanks.

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