Getting java.lang.StackOverflowError: null error during Sonar Run for Python Repository

When running Sonar Cloud workflow for our python repository we are getting java.lang.StackOverflowError: null error. We narrowed down the problem and the issue existed here plugins/module_utils/network/ios/rm_templates . We added the path as sonar exclusion and it worked.

This path has 31 python files which contains complex regexes.

My question is how to resolve this error while including these files as we want sonar to scan these too.

Below are links and logs attached.

Our repository - GitHub - ansible-collections/cisco.ios: Ansible Network Collection for Cisco IOS .

Workflow - ansible-content-actions/.github/workflows/sonarcloud.yaml at main · ansible/ansible-content-actions · GitHub

sonar.properties - cisco.ios/sonar-project.properties at main · ansible-collections/cisco.ios · GitHub

Logs -

1_SonarCloud _ SonarCloud Coverage (Copy).txt (144.8 KB)

An update -

I updated the sonar_exclusions to
sonar.exclusions=tests/**,
plugins/module_utils/network/ios/rm_templates/snmp_server.py,
plugins/module_utils/network/ios/rm_templates/acls.py,
plugins/module_utils/network/ios/rm_templates/l3_interfaces.py,
plugins/module_utils/network/ios/rm_templates/interfaces.py,
plugins/module_utils/network/ios/rm_templates/ospfv2.py,
plugins/module_utils/network/ios/rm_templates/hsrp_interfaces.py,
plugins/module_utils/network/ios/rm_templates/vlans.py,
plugins/module_utils/network/ios/rm_templates/lldp_interfaces.py,
plugins/module_utils/network/ios/rm_templates/logging_global.py,
plugins/module_utils/network/ios/rm_templates/ntp_global.py,
plugins/module_utils/network/ios/rm_templates/user.py,
plugins/module_utils/network/ios/rm_templates/route_maps.py

and now too sonar is working fine. This means it is failing because for the above 12 parser python files.

My question remains same - how to fix sonar scan for these ?

Hi,

Welcome to the community and thanks for this report!

Thanks especially for all the links to all the logs and files in your first post! :star_struck:

I’ve flagged this for the language experts.

 
Ann

Hi @nickbhasin,

Thanks for reaching out. I was able to reproduce the issue locally. I’ve created a ticket on our side to track this.

In the mean time, it seems that increasing the stack size is fixing the issue. Locally, setting SONAR_SCANNER_JAVA_OPTS="-Xss2m" as an environment variable made the analysis run successfully. This should also work when analyzing with the GitHub action by adding the environment variable to the env section of SonarSource/sonarqube-scan-action.

Best,
Sebastian

1 Like