NullPointerException when Probing compiler: [/usr/bin/gcc, -x, c, --std, c99, -v, -dM, -E, -]

I hits into following exception when scanning my CMake C/C++ project with sonar scanner.
Version:

  • SonarScanner: 4.4.0.2170
  • SonarQube server: 7.9.4
05:25:37.981 DEBUG: Using build-wrapper-dump.json probe
05:25:39.249 DEBUG: Probing compiler: [/usr/bin/gcc, -x, c, --std, c99, -v, -dM, -E, -]
05:25:39.249 INFO: [pool-3-thread-1] /home/jenkins/workspace/base/util/func7.cpp
05:25:46.984 INFO: ------------------------------------------------------------------------
05:25:46.984 INFO: EXECUTION FAILURE
05:25:46.984 INFO: ------------------------------------------------------------------------
05:25:46.984 INFO: Total time: 1:15.527s
05:25:47.099 INFO: Final Memory: 32M/110M
05:25:47.099 INFO: ------------------------------------------------------------------------
05:25:47.099 ERROR: Error during SonarScanner execution
java.lang.NullPointerException
        at com.sonar.cpp.analyzer.ClangDriver.envListToMap(ClangDriver.java:510)
        at com.sonar.cpp.analyzer.ClangDriver.lambda$probeCompiler$7(ClangDriver.java:501)
        at java.base/java.util.HashMap.computeIfAbsent(Unknown Source)
        at com.sonar.cpp.analyzer.ClangDriver.probeCompiler(ClangDriver.java:499)
        at com.sonar.cpp.analyzer.ClangDriver.onCapture(ClangDriver.java:326)
        at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:427)
        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: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)

Not sure if related, but this is the output for the gcc command:

# /usr/bin/gcc -x c --std c99 -v -dM -E -
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
COLLECT_GCC_OPTIONS='-std=c99' '-v' '-dM' '-E' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/4.8.5/cc1 -E -quiet -v - -mtune=generic -march=x86-64 -std=c99 -dM
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include
 /usr/local/include
 /usr/include
End of search list.
(hang here until CTRL-C)

Hi @hsrky,

what version of the CFamily plugin do you have installed?

Hi @mpaladin, I am using SonarCFamily 6.8.0.16475

Plugins:
  * Cobertura 2.0 (cobertura)
  * Mutation Analysis 1.5 (mutationanalysis)
  * SonarCSS 1.2.0.1325 (cssfamily)
  * PMD 3.2.1 (pmd)
  * Svn 1.9.0.1295 (scmsvn)
  * SonarPLSQL 3.4.1.2576 (plsql)
  * SonarScala 1.5.0.315 (sonarscala)
  * C# Code Quality and Security 8.6.1.17183 (csharp)
  * Vulnerability Analysis 7.9.0.5105 (security)
  * Java Code Quality and Security 6.3.2.22818 (java)
  * SonarQube CNES Report 3.2.2 (cnesreport)
  * LDAP 2.2.0.608 (ldap)
  * SonarHTML 3.2.0.2082 (web)
  * SonarFlex 2.5.1.1831 (flex)
  * SonarXML 2.0.1.2020 (xml)
  * SonarTS 2.1.0.4359 (typescript)
  * Build Breaker 2.3.1.347 (buildbreaker)
  * Checkstyle 4.21 (checkstyle)
  * VB.NET Code Quality and Security 8.6.1.17183 (vbnet)
  * SonarSwift 4.2.2.77 (swift)
  * Dependency-Check 2.0.6 (dependencycheck)
  * SonarCFamily 6.8.0.16475 (cpp)
  * SonarPython 2.8.0.6204 (python)
  * GitHub Authentication for SonarQube 1.5.0.870 (authgithub)
  * Clover 4.1 (clover)
  * JaCoCo 1.1.0.898 (jacoco)
  * SonarGo 1.6.0.719 (go)
  * SonarKotlin 1.5.0.315 (kotlin)
  * SonarRPG 2.3.0.1187 (rpg)
  * Alcatel-Lucent SONAR-PMD Extension Plugin 2.0 (pmdextensions)
  * SonarPLI 1.10.0.1880 (pli)
  * SonarTSQL 1.4.0.3334 (tsql)
  * SonarVB6 2.6.0.1875 (vb)
  * SonarApex 1.7.0.883 (sonarapex)
  * SonarJS 6.2.1.12157 (javascript)
  * SonarRuby 1.5.0.315 (ruby)
  * Vulnerability Rules for C# 7.9.0.5105 (securitycsharpfrontend)
  * Vulnerability Rules for Java 7.9.0.5105 (securityjavafrontend)
  * License for SonarLint 7.9.4 (license)
  * Findbugs 4.0.1 (findbugs)
  * SonarCOBOL 4.4.0.3403 (cobol)
  * Git 1.11.1.2008 (scmgit)
  * SAML 2.0 Authentication for SonarQube 1.2.0.682 (authsaml)
  * SonarPHP 3.3.0.5166 (php)
  * SonarABAP 3.8.0.2034 (abap)
  * Vulnerability Rules for PHP 7.9.0.5105 (securityphpfrontend)

Hi @hsrky,

could you share the build-wrapper-dump.json file? If you cannot do it here I can send you a PM where you can share privately.

build-wrapper-dump.json (176.7 KB) sonar-output.txt (83.1 KB) sonar-project.txt (588 Bytes)

Related files attached. I masked some source file names inside the logs, I hope this is fine.

Hi @hsrky,

could you share also build-wrapper.log? What version of the build-wrapper are you using?

Hi @mpaladin,
Thanks for looking on the issue.
build-wrapper version:4.5build-wrapper.zip (208.6 KB)

/usr/local/bin/build-wrapper-linux-x86-64 --version
build-wrapper, version 4.5 (linux-x86)
Copyright (C) 2014-2017 SonarSource SA, info@sonarsource.com 

Hi @hsrky,

that is really old, could you please use the one that comes with your SonarQube server? It is good practice to always download it fresh each time.

curl -L -O {$SONARQUBE_URL}/static/cpp/build-wrapper-linux-x86.zip
unzip build-wrapper-linux-x86.zip

Hi @mpaladin,
Thanks for the supports, upgrading build wrapper solved my issue.

$/home/jenkins/workspace/misc/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --version
build-wrapper, version 6.7 (linux-x86)
Copyright (C) 2014-2020 SonarSource SA, info@sonarsource.com
$ /home/jenkins/workspace/misc/sonar-scanner-4.4.0.2170/bin/sonar-scanner --version
INFO: Scanner configuration file: /home/jenkins/workspace/misc/sonar-scanner-4.4.0.2170/conf/sonar-scanner.properties
INFO: Project root configuration file: /home/jenkins/workspace/sonar-project.properties
INFO: SonarScanner 4.4.0.2170
INFO: Java 1.8.0_262 Oracle Corporation (64-bit)
INFO: Linux 4.19.76-linuxkit amd64

Thanks.

1 Like

Hi @hsrky,

great, thank you for the notification.

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