Unable to run sonar-scanner analysis on c project files

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • what are you trying to achieve
  • what have you tried so far to achieve this

I’m using SonarQube version 8.6.1
Having issues running my first build using the tool.
I have attached my properties (sonar-project.properties)file, and im trying to run analysis on my project.
However it fails on the first file itself.sonar-project.txt (910 Bytes)

Below is my error

D:\SonarQube_workspace\SPR>sonar-scanner
INFO: Scanner configuration file: C:\sonarscanner\bin…\conf\sonar-scanner.properties
INFO: Project root configuration file: D:\SonarQube_workspace\SPR\sonar-project.properties
INFO: SonarScanner 4.5.0.2216
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Windows 10 10.0 amd64
INFO: User cache: C:\Users\z0044kAy.sonar\cache
INFO: Scanner configuration file: C:\sonarscanner\bin…\conf\sonar-scanner.properties
INFO: Project root configuration file: D:\SonarQube_workspace\SPR\sonar-project.properties
INFO: Analyzing on SonarQube server 8.6.1
INFO: Default locale: “en_US”, source code encoding: “UTF-8”
INFO: Load global settings
INFO: Load global settings (done) | time=125ms
INFO: Server id: BF41A1F2-AXeLI5s6nzrwJQi0jkI4
INFO: User cache: C:\Users\z0044kAy.sonar\cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=54ms
INFO: Load/download plugins (done) | time=283ms
INFO: Loaded core extensions: developer-scanner
INFO: JavaScript/TypeScript frontend is enabled
INFO: Process project properties
INFO: Process project properties (done) | time=8ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=1ms
INFO: Project key: StaticAnalysis
INFO: Base dir: D:\SonarQube_workspace\SPR
INFO: Working dir: D:\SonarQube_workspace\SPR.scannerwork
INFO: Load project settings for component key: ‘StaticAnalysis’
INFO: Load project settings for component key: ‘StaticAnalysis’ (done) | time=13ms
INFO: Load project branches
INFO: Load project branches (done) | time=13ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=11ms
INFO: Load branch configuration
INFO: Load branch configuration (done) | time=2ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=66ms
INFO: Load active rules
INFO: Load active rules (done) | time=1972ms
WARN: SCM provider autodetection failed. Please use “sonar.scm.provider” to define SCM of your project, or disable the SCM Sensor in the project settings.
INFO: Indexing files…
INFO: Project configuration:
INFO: 266 files indexed
INFO: Quality profile for c: Sonar way
INFO: ------------- Run sensors on module StaticAnalysis
INFO: JavaScript/TypeScript frontend is enabled
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=16ms
INFO: Sensor CSS Rules [cssfamily]
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO: Sensor CSS Rules [cssfamily] (done) | time=4ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=2ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=4ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=5ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=2ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: ‘sonar.coverage.jacoco.xmlReportPaths’ is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=4ms
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend]
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=1ms
INFO: Sensor CFamily [cpp]
INFO: CFamily plugin version: 6.15.1.26715
INFO: Using build-wrapper output: D:\SonarQube_workspace\SPR_sonarqube_build_wrapper\build-wrapper-dump.json
INFO: Available processors: 6
INFO: Using 1 thread for analysis according to value of “sonar.cfamily.threads” property.
INFO: Load project repositories
INFO: Load project repositories (done) | time=18ms
WARN: Invalid character encountered in file D:/SonarQube_workspace/SPR/Firmware/IEC_60870_5_103/MiddleWare/Iec103RxASDU.c at line 559 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
WARN: Invalid character encountered in file D:/SonarQube_workspace/SPR/Firmware/Computation/Application/AppFilterLIP_Inrush.c at line 377 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
WARN: Invalid character encountered in file D:/SonarQube_workspace/SPR/Firmware/Configuration/Application/AppHwConfig.c at line 1048 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
WARN: Invalid character encountered in file D:/SonarQube_workspace/SPR/Firmware/Modbus/Application/AppModbus.c at line 1682 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
WARN: Invalid character encountered in file D:/SonarQube_workspace/SPR/Firmware/IEC_60870_5_103/Application/AppReyEvo.c at line 2193 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
INFO: Cache is explicitly disabled: Optional[false]
INFO: [pool-1-thread-1] D:/SonarQube_workspace/SPR/Application/…/Firmware/ADCDataAcqu/Application/AppADC.c
INFO: Requesting reproducer for: D:/SonarQube_workspace/SPR/Application/…/Firmware/ADCDataAcqu/Application/AppADC.c
ERROR: Exception in thread pool-1-thread-1
com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: D:/SonarQube_workspace/SPR/Application/…/Firmware/ADCDataAcqu/Application/AppADC.c
at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:81)
at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:78)
at com.sonar.cpp.plugin.CFamilySensor.lambda$process$8(CFamilySensor.java:643)
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)

ERROR:
An error occurred while analyzing the following compilation unit:
D:/SonarQube_workspace/SPR/Application/…/Firmware/ADCDataAcqu/Application/AppADC.c
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:
D:\SonarQube_workspace\SPR\sonar-cfamily-reproducer.zip

INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 19.172s
INFO: Final Memory: 20M/74M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException:
An error occurred while analyzing the following compilation unit:
D:/SonarQube_workspace/SPR/Application/…/Firmware/ADCDataAcqu/Application/AppADC.c
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:
D:\SonarQube_workspace\SPR\sonar-cfamily-reproducer.zip

    at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:389)
    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:393)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:389)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
    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:144)
    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)

ERROR:
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

Hello @27.Roger,

I will send you a private message where you can share D:\SonarQube_workspace\SPR\sonar-cfamily-reproducer.zip.

Thnaks,

Hello @27.Roger,

Thanks for sharing the files. I had a look and it seems that you are using an old compiler that is not supported well. Can you try with a newer version of the same compiler? I added a ticket to track the case.

Thanks,

1 Like

Hi,

Sorry my code is specific to the older compiler version.

Hi,

I have tried running it on another code and another compiler toolchain, it seems to be working fine.

Thanks

2 Likes

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