Can't analysis code built with Emscripten

scanner
sonarcfamily
build-wrapper

(Daniel Zhou) #1

OS: GNU/Linux 5.0.7 x86_64
SonarQube: SonarCloud
Scanner: 3.2.0.1227
Plugin: none

The project I am trying to analysis is written in C++ and compiled into WebAssembly with Emscripten which is based on clang.

I got this error when executed build-wrapper and the solution ln -s libinterceptor-x86_64.so libinterceptor-haswell.so worked for me.

Then I executed sonar-scanner and got this:

INFO: Sensor CFamily [cpp]
INFO: Using build-wrapper output: /home/dan/git/regex2dfa/bw-output/build-wrapper-dump.json
INFO: Available processors: 8
INFO: Using 1 thread for analysis according to value of "sonar.cfamily.threads" property.
WARN: Metric 'comment_lines_data' is deprecated. Provided value is ignored.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 25.034s
INFO: Final Memory: 27M/94M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: null
ERROR: 
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.

So I did it again with -X and here it is:

.974 INFO: Sensor CFamily [cpp]
17:10:26.974 INFO: Using build-wrapper output: /home/dan/git/regex2dfa/bw-output/build-wrapper-dump.json
17:10:26.974 INFO: Available processors: 8
17:10:26.975 INFO: Using 1 thread for analysis according to value of "sonar.cfamily.threads" property.
17:10:26.975 DEBUG: Unpacking analyzer to: /home/dan/git/regex2dfa/.scannerwork/.sonartmp/16474349297329944889
17:10:28.225 DEBUG: 'src/dfa.cpp' generated metadata with charset 'UTF-8'
17:10:28.237 WARN: Metric 'comment_lines_data' is deprecated. Provided value is ignored.
17:10:28.239 DEBUG: 'src/dfa.hpp' generated metadata with charset 'UTF-8'
17:10:28.242 DEBUG: 'src/regex2dot.cpp' generated metadata with charset 'UTF-8'
17:10:28.243 DEBUG: Not enough content in 'src/regex2dot.cpp' to have CPD blocks, it will not be part o
f the duplication detection
17:10:28.244 DEBUG: 'src/nfa.hpp' generated metadata with charset 'UTF-8'
17:10:28.247 DEBUG: 'src/nfa.cpp' generated metadata with charset 'UTF-8'
17:10:28.274 DEBUG: Probing compiler: [/usr/lib/emscripten-fastcomp/clang, -x, c++, --std, c++14, -target, asmjs-unknown-emscripten, -v, -dM, -E, -]
17:10:28.449 INFO: ------------------------------------------------------------------------
17:10:28.449 INFO: EXECUTION FAILURE
17:10:28.449 INFO: ------------------------------------------------------------------------
17:10:28.450 INFO: Total time: 25.816s
17:10:28.510 INFO: Final Memory: 27M/97M
17:10:28.510 INFO: ------------------------------------------------------------------------
17:10:28.510 ERROR: Error during SonarQube Scanner execution
java.lang.NullPointerException
        at com.sonar.cpp.analyzer.ClangDriver.envListToMap(ClangDriver.java:470)
        at com.sonar.cpp.analyzer.ClangDriver.lambda$probeCompiler$6(ClangDriver.java:461)
        at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1133)
        at com.sonar.cpp.analyzer.ClangDriver.probeCompiler(ClangDriver.java:459)
        at com.sonar.cpp.analyzer.ClangDriver.onCapture(ClangDriver.java:302)
        at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:266)
        at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:198)
        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:359)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:354)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:317)
        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:128)
        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(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        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:171)
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
        at org.sonarsource.scanner.cli.Main.execute(Main.java:111)

(Massimo Paladin) #2

Hi @nerddan,

could you please share with me privately build-wrapper-dump.json file and the full sonar-scanner log? I am sending you a private message where you can share.