Sonar Scanner C++ error

Template for a good bug report, formatted with Markdown:

  • versions used (SonarQube, Scanner, Plugin, and any relevant extension)
  • error observed (wrap logs/code around triple quote ``` for proper formatting)
  • steps to reproduce
  • potential workaround

P.S.: use the #bug:fault sub-category if you’re hitting a specific crash/error , or the #bug:fp sub-category for rules-related behaviour

The problem is when I integrated SonarQube with Jenkins, I keep getting the same error from sonar scanner. I’ve done build-wrapper before executing sonar-scanner and build-wrapper-dump.json seems fine.

Before causing errors, some of the files succeeded. I checked files that causing error exist. Below is the error I’ve got. I changed succeeded file name as ~ and the files causing error are named as a.cpp and b.cpp. Sorry that I can’t share the details of the files.

  • SonarQube v. 8.3.0.34182
  • Sonar Scanner v4.4.0
  • CFamily plugin version v.6.9.0.17076
INFO: [pool-1-thread-1] ~.cpp
INFO: [pool-1-thread-4] ~.cpp
INFO: [pool-1-thread-3] a.cpp
INFO: Requesting reproducer for: a.cpp
INFO: [pool-1-thread-2] b.cpp
ERROR: Exception in thread pool-1-thread-3
com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: a.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:531)
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: Exception in thread pool-1-thread-2
com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: b.cpp
at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:76)
at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:33)
at com.sonar.cpp.plugin.CFamilySensor.lambda$process$5(CFamilySensor.java:531)
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: 35.936s
INFO: Final Memory: 22M/154M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: a.cpp
at com.sonar.cpp.analyzer.AnalysisExecutor.submit(AnalysisExecutor.java:47)
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:528)
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:471)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:305)
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:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:386)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:382)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:351)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
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:185)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
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: a.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:531)
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 SonarQube Scanner using the -X switch to enable full debug logging.
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeeded?
ERROR: SonarQube scanner exited with non-zero code: 1
Finished: FAILURE

Hello @jaeeun2-choi,

This error means that the analyzer is failing on b.cpp. This should generate a reproducer file in your project directory called sonar-cfamily.reproducer. Please share this file (let me know if you prefer to share it privately) this file will help us identify the reason for the failure. Until then, you can exclude this file from the analysis using sonar.exclusion= PathToFailingFile to unblock.

Can you tell me which part specifically you need from sonar-cfamily.reproducer ? I’m afraid that I can’t share the whole file because it contains source code. Also not just that file some of the files causing the same error.

@jaeeun2-choi,

you cannot even share it privately with me? I will need it to reproduce the scenario that leads to the crash in order to fix it. It will only be used for this purpose. Without it I cannot really help.

Okay. How should I send it privately?
BTW, I updated SonarQube to 8.4.1, Cfamily to 6.11.0.19130 and I still get the same errors.

I’m sorry to rush you but could you do it ASAP? My team is considering buying SonarQube for our c++ project so we got the trial license for the test. It only left 2 days (7/23), or Is it possible to extend our trial license til you solved the problem? We want to see the result before buying it.

@jaeeun2-choi I sent you a PM

@jaeeun2-choi, Thanks for the reproducer. I had a look and I can reproduce the issue. It seems that clang parser is crashing while compiling boost header array_allocator.hpp. Can you check if you can build/analyze with defining this macro BOOST_NO_CXX11_ALLOCATOR (using -D).
Meanwhile, I created this ticket to investigate the issue further and provide a fix on our side.

With -DBOOST_NO_CXX11_ALLOCATOR, same error occurred.

@jaeeun2-choi, can you please share the new reproducer with the build-wrapper.json file privately.

As discussed with @jaeeun2-choi adding -DBOOST_NO_CXX11_ALLOCATOR fixed the analysis.

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