SonarScanner C++ Symbolic Links

System Information:
SonarQube Scanner 4.2.0.1873
Java 11.0.3 AdoptOpenJDK (64-bit)
Linux 5.3.0-40-generic amd64
build-wrapper, version 6.3 (linux-x86)
SonarQube 7.9 LTS

I’ve encountered an issue when attempting to make use of the SonarQube scanner for C++ code in conjunction with the Bullseye code coverage tool.

To reproduce

  • Makefile to build code using the Bullseye g++ compiler
    • This is a symbolic link to their own covc application, which just proxies through to the system g++ whilst generating coverage
  • Generate a coverage.xml using Bullseye covxml
  • Run the sonar build-wrapper on the same makefile target (And so uses the Bullseye g++ compiler)
  • Run sonar-scanner

What we get is the following from the sonar-scanner (However there are times in which this does not occur):

ERROR: Error during SonarQube Scanner execution
java.lang.NullPointerException
        at com.sonar.cpp.analyzer.StdFlags.fromCppMacros(StdFlags.java:23)
        at com.sonar.cpp.analyzer.ClangDriver.onCapture(ClangDriver.java:349)
        at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:273)
        at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:205)
        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:400)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
        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:73)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        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)
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.

Due to the fact our build makes use of the Bullseye g++ compiler, when making use of -X on the sonar-scanner it fails to run as Bullseye’s g++ will error when the -x is passed through to this.

Potential Workaround

It appears that if I remove the symbolic links, replacing them instead of hard links to the covc binary, the sonar-scanner function works as expected.

I assume that this means the issue is when making use of a symbolic link for your compiler, is this something that is known to cause issues?

Hi @56KBs,

this issue doesn’t seem to be related to symbolic links.

Could you please update the SonarCFamily analyzer and the build-wrapper to its latest version 6.7? Many bugs have been fixed in the mean time.