SonarQube C++ analysis errors while using Boost library

Hi, everyone!

We are using SonarQube 8.8.0.42792 Developer Edition to analyse a huge C++ code base. Till now everything was working like a charm. Recently we added Boost library and starting compiling it as a part of the project due to internal requirements. As a result SonarQube (with build-wrapper 6.18.0.29274) and specifically sonar-scanner (sonar-scanner-4.6.0.2311-linux) fail while analyzing even simplest code using boost library. We use Boost 1.79.0 version which was released on 17th March 2022. This is an example app where the analysis fails:

#include <boost/asio.hpp>

int main(int, char**)
{
    boost::asio::io_service m_io;

    m_io.stop();

    return 0;
}

And this is a log we receive (in debug mode with -X option set for sonar-scanner):

Target: x86_64-pc-linux-gnu
Configured with: ../gcc-9.2.0/configure --disable-multilib --disable-nls --enable-languages=c,c++ --program-suffix=-9.2
Thread model: posix
gcc version 9.2.0 (GCC) 
COLLECT_GCC_OPTIONS='-std=c++17' '-v' '-dM' '-E' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/local/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/cc1plus -E -quiet -v -D_GNU_SOURCE - -mtune=generic -march=x86-64 -std=c++17 -dM
ignoring nonexistent directory "/usr/local/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0
 /usr/local/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0/x86_64-pc-linux-gnu
 /usr/local/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0/backward
 /usr/local/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include
 /usr/local/include
 /usr/local/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include-fixed
 /usr/include
End of search list.
COMPILER_PATH=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/:/usr/local/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/:/usr/local/libexec/gcc/x86_64-pc-linux-gnu/:/usr/local/lib/gcc/x86_64-pc-linux-gnu/9.2.0/:/usr/local/lib/gcc/x86_64-pc-linux-gnu/:/usr/local/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/
LIBRARY_PATH=/usr/local/lib/gcc/x86_64-pc-linux-gnu/9.2.0/:/usr/local/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/local/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/lib/:/usr/local/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-std=c++17' '-v' '-dM' '-E' '-shared-libgcc' '-mtune=generic' '-march=x86-64'


02:22:49.131 INFO: [pool-3-thread-1] /home/jenkins/workspace/econ_feature_glass_sonarqube_fix/app_boost_asio_test/boost_asio_test.cpp
02:22:50.605 INFO: Requesting reproducer for: /home/jenkins/workspace/econ_feature_glass_sonarqube_fix/app_boost_asio_test/boost_asio_test.cpp
02:22:52.098 ERROR: Exception in thread pool-3-thread-1
com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: /home/jenkins/workspace/econ_feature_glass_sonarqube_fix/app_boost_asio_test/boost_asio_test.cpp
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:125)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:48)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:122)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:48)
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$8(CFamilySensor.java:714)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
	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)


02:22:52.135 ERROR: 
An error occurred while analyzing the following compilation unit: 
  /home/jenkins/workspace/econ_feature_glass_sonarqube_fix/app_boost_asio_test/boost_asio_test.cpp
A file named "sonar-cfamily-reproducer.zip" has been generated to help the problem investigation.
Please contact SonarSource support providing the following file to help improving the analyzer:
  /home/jenkins/workspace/econ_feature_glass_sonarqube_fix/sonar-cfamily-reproducer.zip


02:22:52.303 INFO: ------------------------------------------------------------------------
02:22:52.303 INFO: EXECUTION FAILURE
02:22:52.303 INFO: ------------------------------------------------------------------------
02:22:52.304 INFO: Total time: 55.414s
02:22:52.624 INFO: Final Memory: 113M/560M
02:22:52.624 INFO: ------------------------------------------------------------------------
02:22:52.624 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: 
An error occurred while analyzing the following compilation unit: 
  /home/jenkins/workspace/econ_feature_glass_sonarqube_fix/app_boost_asio_test/boost_asio_test.cpp
A file named "sonar-cfamily-reproducer.zip" has been generated to help the problem investigation.
Please contact SonarSource support providing the following file to help improving the analyzer:
  /home/jenkins/workspace/econ_feature_glass_sonarqube_fix/sonar-cfamily-reproducer.zip


	at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:390)
	at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:166)
	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:392)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
	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:149)
	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: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)
script returned exit code 1

I can share sonar-cfamily-reproducer file which might help to investigate this issue. However, I noticed that in the past SonarQube team fixed similar issues so the question is whether an upgrade to the latest SonarQube 8.9.10 LTS Developer version would help to solve the problem. If yes can you point an issue in your bug tracker which was fixed as well?

Hi @ihar.hubchyk,

The version that you are using is almost 2 years old, I recommended updating it to 9.8 and trying again as many things have changed since then.

I cannot confirm without investigation if this specific crash is fixed. Looking at how simple the code is, I would guess that it was fixed since we are no longer getting any reports about boost crashes. A candidate ticket: [CPP-2696] - Jira.

Thanks,

Hi @Abbas ,

The workaround from the highlighted JIRA issue helped.

Thank you very much!

@ihar.hubchyk Happy it helped! I still recommend updating to 9.8 when you can to get the right solution instead of the workaround!

Thanks,

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