cnescatlab / cnescatlab/sonar-icode-cnes-plugin

"Java heap space" error in Fortran calltrace without any fortran code to analyze

Open
#74 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
21
Forks
13
PR merge metrics
No merged PRs in 30d

Description

Hello

My sonar-scanner analysis fails with "Java heap space" with F90 or F77 in the calltrace while there's no fortran at all in my code.

Our IT recently upgraded to sonarqube 7.9.5, and I had to upgrade my sonar-scanner from 3.2.0.1227 to 4.5.0.2216 to get it to work (Java was too old in sonar-scanner 3.2). First I got the following backtrace (full log at the end of https://ci.inria.fr/hwloc/job/extended/job/master/285/execution/node/418/log/)
```
12:35:44.178 ERROR: Error during SonarScanner execution
java.lang.OutOfMemoryError: Java heap space
at fr.cnes.icode.fortran90.rules.F90DATAConstantFloat.zzUnpackCMap(F90DATAConstantFloat.java:364)
at fr.cnes.icode.fortran90.rules.F90DATAConstantFloat.(F90DATAConstantFloat.java:77)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Unknown Source)
at fr.cnes.icode.data.xml.XmlHandler.classFromString(XmlHandler.java:87)
at fr.cnes.icode.data.xml.XmlHandler.unmarshal(XmlHandler.java:53)
at fr.cnes.icode.data.CheckersDefinition.addFromResources(CheckersDefinition.java:108)
at fr.cnes.icode.fortran90.rules.Fortran90RulesDefinition.define(Fortran90RulesDefinition.java:27)
at fr.cnes.icode.data.CheckersDefinition.list(CheckersDefinition.java:45)
at fr.cnes.icode.services.checkers.CheckerService.getCheckers(CheckerService.java:60)
at fr.cnes.icode.services.checkers.CheckerService.getCheckers(CheckerService.java:166)
at fr.cnes.icode.Analyzer.stableCheck(Analyzer.java:91)
at fr.cnes.sonar.plugins.icode.check.ICodeSensor.executeEmbeddedICode(ICodeSensor.java:187)
at fr.cnes.sonar.plugins.icode.check.ICodeSensor.execute(ICodeSensor.java:109)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
```

This is running in a VM with 2GB of RAM so I added -Xmx1800m and got a slightly different failure (full log at the end of https://ci.inria.fr/hwloc/job/extended/job/master/286/execution/node/430/log/)
```
java.lang.OutOfMemoryError: Java heap space
at fr.cnes.icode.fortran77.rules.F77ERROpenRead.zzUnpackCMap(F77ERROpenRead.java:431)
at fr.cnes.icode.fortran77.rules.F77ERROpenRead.(F77ERROpenRead.java:76)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Unknown Source)
at fr.cnes.icode.data.xml.XmlHandler.classFromString(XmlHandler.java:87)
at fr.cnes.icode.data.xml.XmlHandler.unmarshal(XmlHandler.java:53)
at fr.cnes.icode.data.CheckersDefinition.addFromResources(CheckersDefinition.java:108)
at fr.cnes.icode.fortran77.rules.Fortran77RulesDefinition.define(Fortran77RulesDefinition.java:27)
at fr.cnes.icode.data.CheckersDefinition.list(CheckersDefinition.java:45)
at fr.cnes.icode.services.checkers.CheckerService.getCheckers(CheckerService.java:60)
at fr.cnes.icode.services.checkers.CheckerService.getCheckers(CheckerService.java:166)
at fr.cnes.icode.Analyzer.stableCheck(Analyzer.java:91)
at fr.cnes.sonar.plugins.icode.check.ICodeSensor.executeEmbeddedICode(ICodeSensor.java:187)
at fr.cnes.sonar.plugins.icode.check.ICodeSensor.execute(ICodeSensor.java:109)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
```

It looks like further increasing -Xmx helps but I can't allocate the entire VM RAM to Java, or other things will start slowing down or failing.

Since we had no clue what was going on with Fortran, we tried disabling icode shell script analysis too (with `sonar.icode.shell.file.suffixes=.noshell`) and this helps too. But this seems totally unrelated, I shouldn't need to disable shell checks to avoid Fortran issues :/

Is it expected to see those F90/F77 calls in the calltrace even when there is no Fortran code to analyze? Is this some static initialization that occurs before sonar-scanner finds out there's no Fortran code to analyze?
Are these allocations indeed big? It looks like there are XML files containing F77 and F90 rules, are those big, which could explain the issue?

Contributor guide

Open the contributing guide

Research direction

Start with the reported stack traces in F90DATAConstantFloat and F77ERROpenRead, then trace CheckersDefinition.addFromResources and Fortran90RulesDefinition/Fortran77RulesDefinition. Reproduce the analysis with no Fortran code, with and without the .noshell suffix setting, using the linked logs and heap settings. Done means the scanner no longer exhausts Java heap while unrelated Fortran rules are loaded.

Written by the indexing model from the issue text.

Assessment

Tech stack
fortran, java, shell
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.