Sonar-scanner is running into an ArrayIndexOutOfBoundsException

Dear all,

sonar-scanner is running into an ArrayIndexOutOfBoundsException when processing our c-files (see below). We are running the latest scanner under Linux.

INFO: SonarQube Scanner 3.3.0.1492
INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
INFO: Linux 4.15.0-45-generic amd64
INFO: User cache: /home/holger/.sonar/cache
INFO: SonarQube server 7.5.0

Any thoughts?

Holger

18:31:04.095 INFO: [pool-4-thread-1] /home/holger/Ebee/LadepunktPlus/controller_software/src/car_comm/slac/common/slac_instr.c
18:31:07.023 INFO: ------------------------------------------------------------------------
18:31:07.023 INFO: EXECUTION FAILURE
18:31:07.023 INFO: ------------------------------------------------------------------------
18:31:07.023 INFO: Total time: 7:12.899s
18:31:07.241 INFO: Final Memory: 22M/444M
18:31:07.241 INFO: ------------------------------------------------------------------------
18:31:07.241 ERROR: Error during SonarQube Scanner execution
java.lang.ArrayIndexOutOfBoundsException: 19380
at com.sonar.cpp.plugin.CFamilySensor.lambda$execute$2(CFamilySensor.java:222)
at java.util.HashMap.forEach(HashMap.java:1288)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:207)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:45)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:88)
at org.sonar.scanner.phases.SensorsExecutor.lambda$execute$1(SensorsExecutor.java:65)
at org.sonar.scanner.phases.SensorsExecutor.withGlobalStrategy(SensorsExecutor.java:80)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:65)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:74)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:164)
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:319)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:314)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:288)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.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.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:131)
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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:185)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)

Hi @Holger_Birkmeyer,

could you please rerun sonar-scanner adding the following property and share with me the generated sonar-cfamily.reproducer plus the slac_instr.c file?

sonar.cfamily.reproducer=/home/holger/Ebee/LadepunktPlus/controller_software/src/car_comm/slac/common/slac_instr.c

Ciao Massimo,

  thank you for taking care of this topic. Requested info is

attached.

Cordiali saluti,

Holger

(Attachment slac_instr.c is missing)

(Attachment sonar-cfamily.reproducer is missing)

Hi @Holger_Birkmeyer,

the attachments are missing, you should rename the files to .txt before uploading them. Be aware you tried to post them here which is public. If you want to share them privately you can message me directly.

Hi @Holger_Birkmeyer,

did you modify the file after the failure? I doubt that the current file with the #if 0 is causing the stacktrace failure you reported at the beginning of the topic.

When I ran into this failure the first time, I had put the #if 0 in the file to see, whether the scanner was unhappy with some content. I have not re-run thre wrapper. I have then re-run the sonar-scanner. The exception was still there.

The run you just requested was definitely running over the slac_instr.c with the #if 0 in it…

If you want me to, I could un-modifiy the file, re-run the wrapper and re-run the scanner and post the results again?

What do you suggest?

@Holger_Birkmeyer yes please, provide sonar-scanner log with failing stacktrace and then create the reproducer without modifying the files in between.

@mpaladin I would like to send you the attachments in private, but cannot figure out, how…

The issue is due to mixed new lines style, in your file there are mixed \n \r\n and \n. The issue comes from a single \r present in the file.

To get it working you can simply normalize line endings of such file. I am not sure we are going to do something on our side. Different editors and wc they all return different line numbers for such file.

Thank you, Massimo. I will fix that asap.
Do I have to re-run the wrapper everytime I change a file?

Hi @Holger_Birkmeyer,

I would recommend you to integrate the analysis with your CI so that each time you build you also analyze the project (of course it requires a clean build).

1 Like