Sonar scanner doesn't work well on large projects for scala

Hi Im using an up to date sonar setup and trying to run the sonarscanner in my ci. One thing thats been a major frustration is that sonar can’t scan large projects with limited memory allocaiton as it runs out of stack space with this recursive call here:

This should probably be done iteratively.

Hi,

Welcome to the community!

Could you give us an idea of the size of your project? And do you feel this is about the number of files, total LOC, size of individual files, or something else?

 
Ann

Had the same problem, scanner crashing in recursive function:

t(ScalaConverter.scala:202) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.$anonfun$convert$4(ScalaConverter.scala:318) at scala.collection.immutable.List.map(List.scala:293) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.convert(ScalaConverter.scala:318) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.createNativeTree(ScalaConverter.scala:285) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.convert(ScalaConverter.scala:202) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.$anonfun$convert$4(ScalaConverter.scala:318) at scala.collection.immutable.List.map(List.scala:293) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.convert(ScalaConverter.scala:318) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.createNativeTree(ScalaConverter.scala:285) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.convert(ScalaConverter.scala:202) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.$anonfun$convert$4(ScalaConverter.scala:318) at scala.collection.immutable.List.map(List.scala:293) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.convert(ScalaConverter.scala:318) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.createNativeTree(ScalaConverter.scala:285) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.convert(ScalaConverter.scala:202) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.$anonfun$convert$4(ScalaConverter.scala:318) at scala.collection.immutable.List.map(List.scala:293) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.convert(ScalaConverter.scala:318) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.createNativeTree(ScalaConverter.scala:285) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.convert(ScalaConverter.scala:202) at org.sonarsource.scala.converter.ScalaConverter$TreeConversion.$anonfun$convert$4(ScalaConverter.scala:318)

Can be reproduced by scanning Kafka repo: GitHub - apache/kafka: Mirror of Apache Kafka

Solved by increasing JVM stack size with SONAR_SCANNER_OPTS environment variable set to -Xss8m.

But this code should be refactored from recursion to iteration, 8M stack is too big.

1 Like

Hello @Pavel_T,

Thanks for your report and for the stacktrace. It seems to me there is a problem there, so I am currently investigating, what we can do.

Meanwhile, could you, please, provide a source file and the stack trace that on your side are known to produce a StackOverflow?

Regards,
Margarita