Hi
I want ot scanner C/C++ code, but there is error, can you help to check it
Run envrioment as below:
sonarqube-8.1.0.31237
sonar-scanner-4.2.0.1873-windows
build-wrapper-win-x86-64.exe
Information as below after runned sonar-scanner:build-wrapper.txt (2.5 MB) build-wrapper-dump.txt (877.4 KB)
19:23:54.133 INFO: ------------------------------------------------------------------------
19:23:54.134 INFO: EXECUTION FAILURE
19:23:54.134 INFO: ------------------------------------------------------------------------
19:23:54.134 INFO: Total time: 42.396s
19:23:54.197 INFO: Final Memory: 27M/100M
19:23:54.198 INFO: ------------------------------------------------------------------------
19:23:54.198 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: java.lang.IllegalStateException: java.io.UTFDataFormatException: malformed input around byte 19
at com.sonar.cpp.analyzer.AnalysisExecutor.submit(AnalysisExecutor.java:47)
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:367)
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:336)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:212)
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: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: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: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)
Caused by: java.lang.IllegalStateException: java.io.UTFDataFormatException: malformed input around byte 19
at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:62)
at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:26)
at com.sonar.cpp.plugin.CFamilySensor.lambda$process$4(CFamilySensor.java:380)
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)
Caused by: java.io.UTFDataFormatException: malformed input around byte 19
at java.base/java.io.DataInputStream.readUTF(Unknown Source)
at java.base/java.io.DataInputStream.readUTF(Unknown Source)
at com.sonar.cpp.analyzer.Protocol.read(Protocol.java:65)
at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:60)
Hi Massimo,
I am as your suggestion to updated sonarCFamily plugin to version 6.6, but unfortunately problems still arise.
I suspect whether there is some wrong configuration in my configuration files, so i show you my configuration as below:
The file “sonar.properties” under sonarQube
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:postgresql://localhost/sonar
sonar.sourceEncoding=UTF-8
The file “sonar-scanner.properties” under sonarScanner:
sonar.jdbc.url=jdbc:postgresql://localhost/sonar
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
The file “sonar-scanner.properties” under souce code:
sonar.projectKey=ATE
sonar.projectName=ATE
sonar.version=0.0.1-SNAPSHOT
sonar.sources=MiniATE_Code_Framework
sonar.cfamily.build-wrapper-output=F:/code/MiniATE_Code_Framework/data
Database is postgreSql, and encoding is UTF8
sonarScanner information as below:
INFO: Scanner configuration file: E:\sonar-scanner-4.2.0.1873-windows\bin…\conf\sonar-scanner.properties
INFO: Project root configuration file: F:\Mini-ATE-GUI\sonar-project.properties
INFO: SonarQube Scanner 4.2.0.1873
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Windows 7 6.1 amd64
In any case I think that the problem comes from the fact that your code base is not UTF-8, when analyzing F:/code/MiniATE_Code_Framework/03_SystemLIB/libCali/./src/libCaliDPpmu.cpp the analyzer fails because of that. Would it be possible to try to run the analysis on your code base encoded with UTF-8?
I am working in windows system, so OS default encoding code is GBK, I have modify the system encoding as UTF-8.
And same time, modify source code file as UTF-8 format. but same issue still happened.
Error infromation as below:
15:21:06.672 ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found but 0 C/C++/Objective-C files were analyzed. Please make sur
e that:
you are using the latest version of the build-wrapper and the SonarCFamily analyzer
you are correctly invoking the scanner with correct configuration * your compiler is supported
you are wrapping your build correctly
you are wrapping a full/clean build
you are providing the path to the correct build-wrapper output directory
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:356)
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: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: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: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)
it’s because you are building in D:\\sonar\\ATE_project\\MiniATE_Code_Framework and analyzing in a different drive: Z:\sonar\ATE_project\MiniATE_Code_Framework. Notice D and Z.
You should build and analyze on the same paths in order for the analyzer to be able to match files.
Hi @mpaladin
Pleasue to received your reponse, thanks for you help to check the issue.
I create a simple project that verify the sonarQube test framework in my local envrionment.
First, as your suggestion, i build and analyze on the same path
But the same issue still happened, detail log as below: build-wrapper.txt (40.3 KB) build-wrapper-dump.json.txt (34.9 KB) output.txt (26.0 KB) sonar-project.properties.txt (129 Bytes)
Hi @mpaladin
I don’t understand “I don’t see any max.c file compilation”, i run the build command, and can see the project have build successfully as below:
If need, i can share you the simple the project, code as below:
max.c
#include “max.h”
int max(int a, int b)
{
return a > b ? a : b;
}