java.lang.IllegalArgumentException: 28 is not a valid line for pointer. File EUCANCB010_p2.rpg has 2

sonar-scanner-cli crash with the error below.
After a long analysis we discover that the problem is if the file start with FOR-EACH syntax.
Example file that can cause crash:

       dcl-pi bug_mwe;                                                                              
         pEntry char(32000);                                                                        
       end-pi;                                                                                      
                                                                                                    
      *********************************************************************************             
      * MAIN                                                                                        
                                                                                                    
       for-each keyValue in %split(pEntry:',');                                                     
       endfor;                                                                                                                                                                        

Example file that works:

DCL-S order_states CHAR(10) DIM(3);
DCL-S state CHAR(20);

order_states(1) = 'Open';
order_states(2) = 'Active';
order_states(3) = 'Closed';
FOR-EACH state in order_states;
   DSPLY state;
ENDFOR;

Crash error:

14:55:50.084 INFO: ------------------------------------------------------------------------
14:55:50.086 INFO: EXECUTION FAILURE
14:55:50.086 INFO: ------------------------------------------------------------------------
14:55:50.092 INFO: Total time: 30.098s
14:55:50.266 INFO: Final Memory: 40M/144M
14:55:50.270 INFO: ------------------------------------------------------------------------
14:55:50.271 ERROR: Error during SonarScanner execution
java.lang.IllegalArgumentException: 28 is not a valid line for pointer. File EUCANCB010_p2.rpg has 27 line(s)
        at org.sonar.api.utils.Preconditions.checkArgument(Preconditions.java:43)
        at org.sonar.api.batch.fs.internal.DefaultInputFile.checkValid(DefaultInputFile.java:371)
        at org.sonar.api.batch.fs.internal.DefaultInputFile.newPointer(DefaultInputFile.java:307)
        at com.sonarsource.rpg.plugin.B.A(Unknown Source)
        at com.sonarsource.rpg.plugin.B.execute(Unknown Source)
        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.lambda$execute$1(ModuleSensorsExecutor.java:61)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:79)
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:61)
        at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:223)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:202)
        at org.sonar.scanner.scan.SpringProjectScanContainer.scan(SpringProjectScanContainer.java:197)
        at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(SpringProjectScanContainer.java:193)
        at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(SpringProjectScanContainer.java:166)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:223)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:202)
        at org.sonar.scanner.bootstrap.SpringScannerContainer.doAfterStart(SpringScannerContainer.java:351)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:223)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:202)
        at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(SpringGlobalContainer.java:138)
        at org.sonar.core.platform.SpringComponentContainer.startComponents(SpringComponentContainer.java:223)
        at org.sonar.core.platform.SpringComponentContainer.execute(SpringComponentContainer.java:202)
        at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:71)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:65)
        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(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
        at jdk.proxy1/jdk.proxy1.$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)
make: *** [scaneuxcod] Error 1
1 Like

Hey there.

As requested in the template post, what version of SonarQube are you using?

The latest: SonarQube 10.4

Hello @Luca_D_Isanto

Thanks very much for your initial investigation and for providing a minimal reproducer, it is really appreciated. I was able to reproduce the error on my side, and I can confirm we are not supporting FOR-EACH syntax correctly.

We have a ticket to improve the situation: SONARRPG-261.

I understand that the situation is annoying, as it prevents any analysis from finishing.
In the meantime, I’m afraid the best workaround is to exclude the files containing for-each. See Narrowing the focus with an analysis scope for more details.

Best,
Quentin

I see that if I declare pEntry like this the scan works.
I think that the scan must end and notify the bug and not crash.

       dcl-pi bug_mwe;                                                                              
         pEntry char(32000);                                                                        
       end-pi;                                                                                      
       pEntry = ''                                                                                             
      *********************************************************************************             
      * MAIN 

       for-each keyValue in %split(pEntry:',');                                                     
       endfor;  
1 Like

ok, thanks for segnalation

Thanks for providing more details on the error, it will help to understand better what is happening.

I agree, this is what we aim for usually, unfortunately, I’m afraid we missed this case.