Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COMFLOWRecursion.checkCircularCalling crash the execution #88

Open
A3lfyr opened this issue Sep 20, 2022 · 1 comment
Open

COMFLOWRecursion.checkCircularCalling crash the execution #88

A3lfyr opened this issue Sep 20, 2022 · 1 comment

Comments

@A3lfyr
Copy link

A3lfyr commented Sep 20, 2022

Hello,
I hope you can help me

Describe the bug

When I run a scan (sonar-scanner command or in a docker container sonarsource/sonar-scanner-cli or lequal/sonar-scanner) on a project containing some shell files, the scan execution crashes with the following error:

...
INFO: Sensor Sonar i-Code [icode]
INFO: Reflections took 182 ms to scan 12 urls, producing 26 keys and 242 values
INFO: Reflections took 139 ms to scan 12 urls, producing 26 keys and 242 values
INFO: Reflections took 114 ms to scan 12 urls, producing 26 keys and 242 values
INFO: Reflections took 103 ms to scan 12 urls, producing 26 keys and 242 values
INFO: Reflections took 94 ms to scan 12 urls, producing 26 keys and 242 values
INFO: Reflections took 100 ms to scan 12 urls, producing 26 keys and 242 values
INFO: Reflections took 95 ms to scan 12 urls, producing 26 keys and 242 values
INFO: Reflections took 94 ms to scan 12 urls, producing 26 keys and 242 values
INFO: Reflections took 92 ms to scan 12 urls, producing 26 keys and 242 values
INFO: Reflections took 108 ms to scan 12 urls, producing 26 keys and 242 values
INFO: Reflections took 97 ms to scan 12 urls, producing 26 keys and 242 values
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 8.222s
INFO: Final Memory: 562M/940M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.StackOverflowError
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:424)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
...

I have this problem on 2 different projects, but it does not appear on all projects containing shell code.

This problem is not solved by disabling the COM.FLOW.Recursion rule in the associated quality profile

This problem does not occur anymore if I deactivate the i-Code CNES plugin.

To reproduce

The problem is difficult to reproduce because it appears only on certain projects, projects for which the sources cannot be shared.

Screenshots & log

Here is the stacktrace using the debug mode of sonar-scanner (argument -X):

...
13:05:07.129 INFO: Reflections took 95 ms to scan 12 urls, producing 26 keys and 242 values
13:05:07.130 DEBUG: expanded subtype org.sonar.api.scanner.sensor.ProjectSensor -> org.sonar.api.batch.sensor.Sensor
13:05:07.130 DEBUG: expanded subtype java.lang.Throwable -> java.lang.Exception
13:05:07.130 DEBUG: expanded subtype java.io.Serializable -> java.lang.Throwable
13:05:07.130 DEBUG: expanded subtype com.thoughtworks.xstream.mapper.Mapper -> com.thoughtworks.xstream.mapper.MapperWrapper
13:05:07.130 DEBUG: expanded subtype com.thoughtworks.xstream.converters.Converter -> com.thoughtworks.xstream.converters.extended.ToAttributedValueConverter
13:05:07.130 DEBUG: expanded subtype com.thoughtworks.xstream.converters.ConverterMatcher -> com.thoughtworks.xstream.converters.Converter
13:05:07.130 DEBUG: expanded subtype org.sonar.api.resources.Language -> org.sonar.api.resources.AbstractLanguage
13:05:07.131 DEBUG: going to scan these urls:
jar:file:/home/***/.sonar/cache/89b582ef2b351828038c71cf4f0b877f/sonar-icode-plugin.jar_unzip/META-INF/lib/icode-library-v4.1.0.jar!/
jar:file:/home/***/.sonar/cache/89b582ef2b351828038c71cf4f0b877f/sonar-icode-plugin.jar_unzip/META-INF/lib/shell-language-v4.1.0.jar!/
jar:file:/home/***/.sonar/cache/89b582ef2b351828038c71cf4f0b877f/sonar-icode-plugin.jar_unzip/META-INF/lib/fortran90-language-v4.1.0.jar!/
jar:file:/home/***/.sonar/cache/89b582ef2b351828038c71cf4f0b877f/sonar-icode-plugin.jar_unzip/META-INF/lib/fortran90-metrics-v4.1.0.jar!/
jar:file:/home/***/.sonar/cache/89b582ef2b351828038c71cf4f0b877f/sonar-icode-plugin.jar_unzip/META-INF/lib/shell-rules-v4.1.0.jar!/
jar:file:/home/***/.sonar/cache/89b582ef2b351828038c71cf4f0b877f/sonar-icode-plugin.jar_unzip/META-INF/lib/fortran77-rules-v4.1.0.jar!/
jar:file:/home/***/.sonar/cache/89b582ef2b351828038c71cf4f0b877f/sonar-icode-plugin.jar_unzip/META-INF/lib/icode-core-v4.1.0.jar!/
jar:file:/home/***/.sonar/cache/89b582ef2b351828038c71cf4f0b877f/sonar-icode-plugin.jar_unzip/META-INF/lib/fortran77-language-v4.1.0.jar!/
jar:file:/home/***/.sonar/cache/89b582ef2b351828038c71cf4f0b877f/sonar-icode-plugin.jar_unzip/META-INF/lib/fortran90-rules-v4.1.0.jar!/
jar:file:/home/***/.sonar/cache/89b582ef2b351828038c71cf4f0b877f/sonar-icode-plugin.jar!/
jar:file:/home/***/.sonar/cache/89b582ef2b351828038c71cf4f0b877f/sonar-icode-plugin.jar_unzip/META-INF/lib/shell-metrics-v4.1.0.jar!/
jar:file:/home/***/.sonar/cache/89b582ef2b351828038c71cf4f0b877f/sonar-icode-plugin.jar_unzip/META-INF/lib/fortran77-metrics-v4.1.0.jar!/
13:05:07.243 INFO: Reflections took 112 ms to scan 12 urls, producing 26 keys and 242 values
13:05:07.244 DEBUG: expanded subtype org.sonar.api.scanner.sensor.ProjectSensor -> org.sonar.api.batch.sensor.Sensor
13:05:07.244 DEBUG: expanded subtype java.lang.Throwable -> java.lang.Exception
13:05:07.244 DEBUG: expanded subtype java.io.Serializable -> java.lang.Throwable
13:05:07.244 DEBUG: expanded subtype com.thoughtworks.xstream.mapper.Mapper -> com.thoughtworks.xstream.mapper.MapperWrapper
13:05:07.244 DEBUG: expanded subtype com.thoughtworks.xstream.converters.Converter -> com.thoughtworks.xstream.converters.extended.ToAttributedValueConverter
13:05:07.244 DEBUG: expanded subtype com.thoughtworks.xstream.converters.ConverterMatcher -> com.thoughtworks.xstream.converters.Converter
13:05:07.244 DEBUG: expanded subtype org.sonar.api.resources.Language -> org.sonar.api.resources.AbstractLanguage
13:05:09.425 INFO: ------------------------------------------------------------------------
13:05:09.425 INFO: EXECUTION FAILURE
13:05:09.425 INFO: ------------------------------------------------------------------------
13:05:09.425 INFO: Total time: 7.371s
13:05:09.483 INFO: Final Memory: 562M/939M
13:05:09.483 INFO: ------------------------------------------------------------------------
13:05:09.483 ERROR: Error during SonarScanner execution
java.lang.StackOverflowError
        at java.base/java.util.ArrayList.indexOfRange(Unknown Source)
        at java.base/java.util.ArrayList.indexOf(Unknown Source)
        at java.base/java.util.ArrayList.contains(Unknown Source)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:426)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
        at fr.cnes.icode.shell.rules.COMFLOWRecursion.checkCircularCalling(COMFLOWRecursion.java:433)
...

User environment

  • OS: CentOS Linux 7
  • Java version: 1.8.0_342
  • i-Code version: 2.2.0

Run scan directly with the sonar-scanner command or in a docker container sonarsource/sonar-scanner-cli or lequal/sonar-scanner

@A3lfyr
Copy link
Author

A3lfyr commented Sep 30, 2022

I managed to isolate the problematic file by dichotomy.
In the same way I understood that the problem came from an apostrophe in an EOU block in a shell script :

  cat <<-EOU
  ...
  this script's directory
  ...

EOU

The solution was to delete this apostrophe

  cat <<-EOU
  ...
  this script s directory
  ...

EOU

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant