AnalyzerException + IllegalStateException with TI ARM Compiler

AnalyzerException + IllegalStateException with TI ARM Compiler

When upgrading from SonarQube 7.9 LTS to 8.9 LTS, we migrated a project that was
previously bypassing the build-wrapper. When analyzing the project with the new
executables, sonar-scanner appears to consistently crash. When I added the
offending file to sonar.exclusions the very next (alphabetical) file caused
an equivalent backtrace.

Legal has asked I attach an NDA before sending over the compilation unit in
question (contained within sonar-cfamily-reproducer.zip).

Versions

  • SonarQube Developer Edition: version 8.9 (build 43852)
  • sonar-scanner
    • INFO: Scanner configuration file: C:\BuildTools\sonar-scanner-4.6\bin…\conf\sonar-scannerproperties
    • INFO: Project root configuration file: C:\Users\bamboo\Desktop\SomeProject\sonar-project.properties
    • INFO: SonarScanner 4.6.2.2472
    • INFO: Java 11.0.11 AdoptOpenJDK (64-bit)
    • INFO: Windows 10 10.0 amd64
  • CFamily plugin version: 6.20.0.31240
  • build-wrapper, version 6.20 (win-x86-64)
  • TI ARM Compiler 16.9.1.LTS

Backtrace

15:43:03.562 DEBUG: Probing compiler: [C:\ti\ccsv7\tools\compiler\ti-cgt-c2000_6.4.12\bin\cl2000.exe, -Ooff, --preproc_macros, C:\Users\bamboo\AppData\Local\Temp\probe6087565634841062898.tmp]
15:43:03.796 DEBUG: stdout:

15:43:03.796 DEBUG: stderr:

15:43:03.812 DEBUG: probe:
 #define __signed_chars__ 1     /* Predefined */
#define __DATE__ "Sep 20 2021"  /* Predefined */
#define __TIME__ "15:43:03"     /* Predefined */
#define __STDC__ 1      /* Predefined */
#define __STDC_VERSION__ 199409L        /* Predefined */
#define __edg_front_end__ 1     /* Predefined */
#define __EDG_VERSION__ 404     /* Predefined */
#define __EDG_SIZE_TYPE__ unsigned long /* Predefined */
#define __EDG_PTRDIFF_TYPE__ long       /* Predefined */
#define __GNUC_GNU_INLINE__ 1   /* Predefined */
#define __GNUC_MINOR__ 3        /* Predefined */
#define __GNUC_PATCHLEVEL__ 0   /* Predefined */
#define __VERSION__ "EDG gcc 4.3 mode"  /* Predefined */
#define __TI_COMPILER_VERSION__ 6004012 /* Predefined */
#define __COMPILER_VERSION__ 6004012    /* Predefined */
#define __TMS320C2000__ 1       /* Predefined */
#define _TMS320C2000 1  /* Predefined */
#define __TMS320C28XX__ 1       /* Predefined */
#define _TMS320C28XX 1  /* Predefined */
#define __TMS320C28X__ 1        /* Predefined */
#define _TMS320C28X 1   /* Predefined */
#define __LARGE_MODEL__ 1       /* Predefined */
#define __SIZE_T_TYPE__ unsigned long   /* Predefined */
#define __PTRDIFF_T_TYPE__ long /* Predefined */
#define __WCHAR_T_TYPE__ unsigned int   /* Predefined */
#define __little_endian__ 1     /* Predefined */
#define __TI_STRICT_ANSI_MODE__ 0       /* Predefined */
#define __TI_WCHAR_T_BITS__ 16  /* Predefined */
#define __TI_GNU_ATTRIBUTE_SUPPORT__ 1  /* Predefined */
#define __TI_STRICT_FP_MODE__ 1 /* Predefined */
#define _OPTIMIZE_FOR_SPACE 1


15:43:03.827 INFO: [pool-1-thread-1] C:/Users/bamboo/Desktop/SomeProject/Debug/../Source/AGC_Task.c
15:43:20.093 INFO: Requesting reproducer for: C:/Users/bamboo/Desktop/SomeProject/Debug/../Source/AGC_Task.c
15:43:24.781 ERROR: Exception in thread pool-1-thread-1
com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: C:/Users/bamboo/Desktop/SomeProject/Debug/../Source/AGC_Task.c
        at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:130)
        at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:50)
        at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:127)
        at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:50)
        at com.sonar.cpp.plugin.CFamilySensor.lambda$process$8(CFamilySensor.java:718)
        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)

15:43:24.905 ERROR:
An error occurred while analyzing the following compilation unit:
  C:/Users/bamboo/Desktop/SomeProject/Debug/../Source/AGC_Task.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:\Users\bamboo\Desktop\SomeProject\sonar-cfamily-reproducer.zip

15:43:25.218 INFO: ------------------------------------------------------------------------
15:43:25.218 INFO: EXECUTION FAILURE
15:43:25.218 INFO: ------------------------------------------------------------------------
15:43:25.218 INFO: Total time: 1:01.705s
15:43:25.390 INFO: Final Memory: 20M/70M
15:43:25.390 INFO: ------------------------------------------------------------------------
15:43:25.390 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException:
An error occurred while analyzing the following compilation unit:
  C:/Users/bamboo/Desktop/SomeProject/Debug/../Source/AGC_Task.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:\Users\bamboo\Desktop\SomeProject\sonar-cfamily-reproducer.zip

        at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:396)
        at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:175)
        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:392)
        at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
        at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
        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:150)
        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)

sonar-project.properties

# Required metadata
sonar.projectKey=SomeProject
sonar.projectName=SomeProject

# Bamboo should overwrite this value with build number
sonar.projectVersion=0.0.0

# Comma-separated paths to directories with sources (required)
sonar.sources=./Source,./Include
sonar.exclusions=\
  Source/ISR.c,\
  SomeProjectcfg_c.c,\
  SomeProjectcfg.h,\
  Include/IQmathLib.h
sonar.cfamily.library.directories=\
  .,\
  ./Include,\
  ./Test/mock

# preprocessor macros
sonar.cfamily.predefinedMacros=\
  #define __interrupt,\
  #define __no_init,\
  #define __root,\
  #define __IO,\
  #define __I,\
  #define _STD_BEGIN,\
  #define _STD_END,\
  #define cregister,\
  #define _TMS320C28X

# Language, needed for SonarQube < 4.2
sonar.language=c
sonar.c.std=c99

# Encoding of the source files
sonar.sourceEncoding=windows-1252

# source control
sonar.scm.provider=svn

# links
sonar.links.homepage=http://wiki.msasafety.com/display/SomeProject
sonar.links.ci=http://bamboo.msasafety.com/browse/SomeProject
sonar.links.issue=http://jira.msasafety.com/projects/SomeProject
sonar.links.scm=http://source.msasafety.com/changelog/SomeProject
$ file -bi AGC_Task.c
text/x-c; charset=us-ascii

Sonar Command Line

if not exist .sonar-wrapper mkdir .sonar-wrapper
"C:\Tools\build-wrapper-win-x86\6.20\build-wrapper-win-x86-64.exe" --out-dir .sonar-wrapper mingw32-make -f bamboo.mk firmware
"C:\BuildTools\sonar-scanner-4.6\bin\sonar-scanner.bat" -Dsonar.projectVersion=0.0 -Dsonar.host.url=http://10.16.5.212:9000/ -Dsonar.cfamily.build-wrapper-output=.sonar-wrapper -X

Processing: SonarSource NDA 2021-09-21.docx…
SonarSource NDA 2021-09-21.zip (45.9 KB)

Hello @JonPovirk,

Does it work if I send you a private message where you share the reproducer zip with me?
Note:

These 3 options are not considered by the analyzer.

Thanks,

Hi Abbas,

I’ve been cleared to send the file! Apologies for the delay (got to love protocol).

1 Like

Hello @JonPovirk,

Thanks for providing the reproducer.

Just to clarify, looking at the build-wrapper JSON the compiler for the failing files is ti-cgt-c2000_6.4.12\\bin\\cl2000.exe.

When we probe the compiler we expect some macros as an output that helps us do the analysis. In your case we get:

#define signed_chars 1 /* Predefined /
#define DATE “Sep 20 2021” /
Predefined /
#define TIME “15:43:03” /
Predefined /
#define STDC 1 /
Predefined /
#define STDC_VERSION 199409L /
Predefined /
#define edg_front_end 1 /
Predefined /
#define EDG_VERSION 404 /
Predefined /
#define EDG_SIZE_TYPE unsigned long /
Predefined /
#define EDG_PTRDIFF_TYPE long /
Predefined /
#define GNUC_GNU_INLINE 1 /
Predefined /
#define GNUC_MINOR 3 /
Predefined /
#define GNUC_PATCHLEVEL 0 /
Predefined /
#define VERSION “EDG gcc 4.3 mode” /
Predefined /
#define TI_COMPILER_VERSION 6004012 /
Predefined /
#define COMPILER_VERSION 6004012 /
Predefined /
#define TMS320C2000 1 /
Predefined /
#define _TMS320C2000 1 /
Predefined /
#define TMS320C28XX 1 /
Predefined /
#define _TMS320C28XX 1 /
Predefined /
#define TMS320C28X 1 /
Predefined /
#define _TMS320C28X 1 /
Predefined /
#define LARGE_MODEL 1 /
Predefined /
#define SIZE_T_TYPE unsigned long /
Predefined /
#define PTRDIFF_T_TYPE long /
Predefined /
#define WCHAR_T_TYPE unsigned int /
Predefined /
#define little_endian 1 /
Predefined /
#define TI_STRICT_ANSI_MODE 0 /
Predefined /
#define TI_WCHAR_T_BITS 16 /
Predefined /
#define TI_GNU_ATTRIBUTE_SUPPORT 1 /
Predefined /
#define TI_STRICT_FP_MODE 1 /
Predefined */
#define _OPTIMIZE_FOR_SPACE 1

But we don’t get the expected standard one like:
__SIZEOF_INT__

I think this is because the compiler is old. We are considering extending our support for older compilers.

May you try with a newer version or is this is a blocker for you?

Thanks,

I ended up making a fake version of the build wrapper output that pretends the project was compiled with clang. We don’t want to update the compiler for approvals reasons, but the workaround was good enough to keep us functioning!
From my perspective, this ticket can be closed

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