[Urgent] Error reproted during SonarQube scanner execution

Error reproted during SonarQube scanner execution. SonarQube scanner run in the WIN10.

Below is the version of SonarQube we used.
- SonarScanner 4.8.0.2856
- build-wrapper version 6.41

The code run in the processor TI MSP430F5329, language C. The code is built by CCS7.3.0.

Below is the part of error log. I also attched the‘sonar-cfamily-reproducer.zip’ log.

Hope you can give me some suggestions to troubleshoot this issue. Thank you.


sonar-cfamily-reproducer.zip (87.9 KB)

09:51:38.010595 ERROR
An error occurred while analyzing the following compilation unit:
C:/SonarQubeScan/PROECodeScan/PROEsourcecode/FWV1.82R00/Debug/…/acm.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:
C:\SonarQubeScan\PROECodeScan\sonar-cfamily-reproducer.zip

java.lang.IllegalStateException:
An error occurred while analyzing the following compilation unit:
C:/SonarQubeScan/PROECodeScan/PROEsourcecode/FWV1.82R00/Debug/…/acm.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:
C:\SonarQubeScan\PROECodeScan\sonar-cfamily-reproducer.zip

at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:442)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:215)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:64)
at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:403)
at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:399)
at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:368)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:137)
at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:188)
at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:167)
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:126)
at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
at org.sonarsource.scanner.cli.Main.main(Main.java:62)

Hi @heat_huang, welcome to our community!

This crash was already tracked by CPP-3940 and CPP-3550, so that we rather report a user-friendly error message instead of continuing with the analysis and crashing later in case some expected macros are not present/provided, such as: __SIZEOF_POINTER__ or __SIZEOF_INT__, etc.
In case those macros are not defined, it’s not clear what are the sizes of the fundamental types on the platform, hence we cannot reasonably continue.
This improvement was already released, so by using our latest scanner you should no longer crash, but have some error message instead.

In CPP-3986, we should explore if we can guess the size of such fundamental types and gracefully continue the analysis even in such cases.

In the meantime, you could try to define the necessary macros directly, according to your platform.
Let me know if defining those manually helped!

Thank you for reporting this issue.

Hi balazs.benics ,

Thank you for your support.

I download the SonarScanner from this link: https://docs.sonarqube.org/latest/analyzing-source-code/scanners/sonarscanner/. Is SonarScanner 4.8.0.2856 the latest version? If not, where to download the latest one?

You mean the error caused by some expected macros are not present/provided. I also checked the reproducer file, “Target triple” is x86_64-unknown-unknown. But how to define the necessary macros directly? In the source code? or In some sonarqube related configuration file? Which macros are necessary?

You are correct. My bad. The fix is only present in an unreleased version. You should expect it in the next release, which is due soon.

Most compilers have flags for defining macros. In GCC and Clang the command line flags are -DMYMACRO=foobar. If you are using CMake, then you can use target_compile_definitions() or add_definitions() to add the necessary flags to your build system.

After the such flags are passed to the build system, the Sonar’s build-wrapper can be used to log the build system and save some metadata of the environment where the build happened, what compiler and flags are being used, etc. So, this is the part when we will see a compiler invocation using those flags defining the macros we are interested in.

In your case, according to the build-wrapper.log, you are using a Texas Instruments compiler (cl430), for which the online documentation says, that it also uses the -D flag for defining macros, as GCC and Clang does. So, the required macro definitions probably look like:
-D__SIZEOF_INT__=42 -D__SIZEOF_LONG__=42 -D__SIZEOF_LONG_LONG__=42 -D__SIZEOF_FLOAT__=42 -D__SIZEOF_DOUBLE__=42 -D__SIZEOF_LONG_DOUBLE__=42

You should replace all 42 values there with the corresponding values matching your target.

For this, consult the compiler’s documentation or just write a small program that prints out the sizeof()s of the different types.

After this if you clean your build directory, re-log and analyze your project, it should work.

1 Like

Hi balazs.benics ,

I added the required macro definitions in the CCS compiler(Predefined Symbols) manually. Then SonarQube scanner run successfully. Analysis report also uploaded the SonarQube.

Thank you.

Great news!

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