Unable to run the SonarScan to complete the task

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    latest stable
  • what are you trying to achieve
    run a scan on my wordpress
  • what have you tried so far to achieve this
    Created the new project in sonarqube,
    downloaded the plugin
    runned the plugin

Results always in a fail after several minutes:

07:45:54.591 DEBUG: eslint-bridge server will shutdown
07:45:54.777 INFO: ------------------------------------------------------------------------
07:45:54.777 INFO: EXECUTION FAILURE
07:45:54.777 INFO: ------------------------------------------------------------------------
07:45:54.777 INFO: Total time: 6:45.184s
07:45:54.813 INFO: Final Memory: 13M/50M
07:45:54.813 INFO: ------------------------------------------------------------------------
07:45:54.813 ERROR: Error during SonarScanner execution
java.lang.OutOfMemoryError: Java heap space
	at java.base/java.util.Arrays.copyOf(Unknown Source)
	at java.base/java.util.ArrayList.grow(Unknown Source)
	at java.base/java.util.ArrayList.grow(Unknown Source)
	at java.base/java.util.ArrayList.add(Unknown Source)
	at java.base/java.util.ArrayList.add(Unknown Source)
	at org.sonar.php.checks.InheritanceDepthCheck.checkClassInheritance(InheritanceDepthCheck.java:95)
	at org.sonar.php.checks.InheritanceDepthCheck.visitClassDeclaration(InheritanceDepthCheck.java:64)
	at org.sonar.php.tree.impl.declaration.ClassDeclarationTreeImpl.accept(ClassDeclarationTreeImpl.java:170)
	at org.sonar.plugins.php.api.visitors.PHPVisitorCheck.scan(PHPVisitorCheck.java:567)
	at org.sonar.plugins.php.api.visitors.PHPVisitorCheck.visitScript(PHPVisitorCheck.java:497)
	at org.sonar.php.tree.impl.ScriptTreeImpl.accept(ScriptTreeImpl.java:70)
	at org.sonar.plugins.php.api.visitors.PHPVisitorCheck.scan(PHPVisitorCheck.java:567)
	at org.sonar.plugins.php.api.visitors.PHPVisitorCheck.visitCompilationUnit(PHPVisitorCheck.java:502)
	at org.sonar.plugins.php.api.visitors.PHPVisitorCheck.analyze(PHPVisitorCheck.java:592)
	at org.sonar.php.PHPAnalyzer.analyze(PHPAnalyzer.java:100)
	at org.sonar.plugins.php.PHPSensor$AnalysisScanner.scanFile(PHPSensor.java:197)
	at org.sonar.plugins.php.Scanner.processFile(Scanner.java:69)
	at org.sonar.plugins.php.Scanner.execute(Scanner.java:57)
	at org.sonar.plugins.php.Scanner.execute(Scanner.java:43)
	at org.sonar.plugins.php.PHPSensor.execute(PHPSensor.java:128)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor$$Lambda$322/0x000000010060e840.run(Unknown Source)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:393)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:389)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)

I have also increased the memory for JS

[root@apa uhl.site]# /root/sonar-scanner-4.5.0.2216-linux/bin/sonar-scanner   -Dsonar.projectKey=uhl-site   -Dsonar.sources=.   -Dsonar.host.url=http://137.74.247.206:9000   -Dsonar.login=f1a59dfbd88021d4256f883473b1678be1e2555b -X
08:52:37.741 INFO: Scanner configuration file: /root/sonar-scanner-4.5.0.2216-linux/conf/sonar-scanner.properties
08:52:37.744 INFO: Project root configuration file: /www/wwwroot/uhl.site/sonar-project.properties
08:52:37.760 INFO: SonarScanner 4.5.0.2216
08:52:37.760 INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
08:52:37.760 INFO: Linux 4.18.0-193.28.1.el8_2.x86_64 amd64
08:52:37.760 INFO: **SONAR_SCANNER_OPTS=-Xmx512m**

It did not seem to make a difference.

Hi,

You need to give the scanner (not JS) more memory. The docs should help.

 
Ann

HI,

have already increased the java memory SONAR_SCANNER_OPTS=-Xmx512m and it does not help.

Hi,

512m isn’t really that much. Generally the procedure is to keep increasing it until it’s enough to accommodate your analysis. Your other option is to exclude code, but I don’t recommend that.

 
:woman_shrugging:
Ann

Roger that, will play with this then, il move to 1Gb and see how it goes.

I am now passing from 2Gb to 4Gb, it stops on same spot, no matter the size of memory set

21:30:54.088 DEBUG: eslint-bridge server will shutdown
21:30:54.564 DEBUG: stylelint-bridge server will shutdown
21:30:54.567 INFO: ------------------------------------------------------------------------
21:30:54.567 INFO: EXECUTION FAILURE
21:30:54.567 INFO: ------------------------------------------------------------------------
21:30:54.567 INFO: Total time: 6:56.087s
21:30:54.715 INFO: Final Memory: 13M/54M
21:30:54.715 INFO: ------------------------------------------------------------------------
21:30:54.715 ERROR: Error during SonarScanner execution
java.lang.OutOfMemoryError: Java heap space
	at java.base/java.util.Arrays.copyOf(Unknown Source)
	at java.base/java.util.ArrayList.grow(Unknown Source)
	at java.base/java.util.ArrayList.grow(Unknown Source)
	at java.base/java.util.ArrayList.add(Unknown Source)
	at java.base/java.util.ArrayList.add(Unknown Source)
	at org.sonar.php.checks.InheritanceDepthCheck.checkClassInheritance(InheritanceDepthCheck.java:95)
	at org.sonar.php.checks.InheritanceDepthCheck.visitClassDeclaration(InheritanceDepthCheck.java:64)
	at org.sonar.php.tree.impl.declaration.ClassDeclarationTreeImpl.accept(ClassDeclarationTreeImpl.java:170)
	at org.sonar.plugins.php.api.visitors.PHPVisitorCheck.scan(PHPVisitorCheck.java:567)
	at org.sonar.plugins.php.api.visitors.PHPVisitorCheck.visitScript(PHPVisitorCheck.java:497)
	at org.sonar.php.tree.impl.ScriptTreeImpl.accept(ScriptTreeImpl.java:70)
	at org.sonar.plugins.php.api.visitors.PHPVisitorCheck.scan(PHPVisitorCheck.java:567)
	at org.sonar.plugins.php.api.visitors.PHPVisitorCheck.visitCompilationUnit(PHPVisitorCheck.java:502)
	at org.sonar.plugins.php.api.visitors.PHPVisitorCheck.analyze(PHPVisitorCheck.java:592)
	at org.sonar.php.PHPAnalyzer.analyze(PHPAnalyzer.java:100)
	at org.sonar.plugins.php.PHPSensor$AnalysisScanner.scanFile(PHPSensor.java:197)
	at org.sonar.plugins.php.Scanner.processFile(Scanner.java:69)
	at org.sonar.plugins.php.Scanner.execute(Scanner.java:57)
	at org.sonar.plugins.php.Scanner.execute(Scanner.java:43)
	at org.sonar.plugins.php.PHPSensor.execute(PHPSensor.java:128)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor$$Lambda$322/0x000000080060e840.run(Unknown Source)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:393)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:389)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
[root@apa uhl.site]# 

I do not think are big differences on quiting message, from 512 mb to 4 gb no change?

Hi,

How big is your project? And/or do you have any particularly large files in it? The memory required for analysis is proportionate to the input (project) size.

 
Ann

When speaking of size of project il say its a wordpress project. All files around 50 mb.

Best Regards,
Cosmin M.
Uhl Hosting

Hi Cosmin,

I would call that large. You should continue increasing the memory allocation. That or maybe try halving what’s being analyzed.

 
Ann

P.S. I’ve updated the tags on this thread from java to php

Sorry, I didn’t see this post before.
This is a known problem in our PHP analyzer which was already fixed.
The fix is already available in SonarCloud and will be available in SonarQube 8.6 when it’s released.

As a temporary workaround, you can disable the rule php:S110.

2 Likes

@pynicolas thank you!

INFO: CPD Executor CPD calculation finished (done) | time=1432ms
INFO: Analysis report generated in 451ms, dir size=74 MB
INFO: Analysis report compressed in 3823ms, zip size=24 MB
INFO: Analysis report uploaded in 401ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://137.74.247.206:9000/dashboard?id=uhl-site
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://137.74.247.206:9000/api/ce/task?id=AXZE_jZmgxMShpCWM_Rw
INFO: Analysis total time: 7:16.489 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 7:17.131s
INFO: Final Memory: 15M/60M
INFO: ------------------------------------------------------------------------
[root@apa uhl.site]# 

@ganncamp seems that this solution from Pierre works, maybe you can add this to bookmark in case someone else hits same issue, increasing the RAM won’t help, in fact I was sure 4 GB is way too much. Even it did not needed any increases and see memory consumption.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.