java.lang.OutOfMemoryError: Java heap space using Microsoft hosted agents after

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps, using ubuntu-latest, Microsoft hosted agents
  • Scanner command used when applicable: SonarCloudAnalyze@1
  • Languages of the repository: C#, Typescript
  • Error observed
2023-10-10T09:51:05.1245637Z 09:51:05.123 DEBUG: the bridge server closed
2023-10-10T09:51:05.1245991Z 09:51:05.123 INFO: Time spent writing ucfgs 80ms
2023-10-10T09:51:05.6583735Z 09:51:05.657 INFO: ------------------------------------------------------------------------
2023-10-10T09:51:05.6592770Z 09:51:05.659 INFO: EXECUTION FAILURE
2023-10-10T09:51:05.6600854Z 09:51:05.659 INFO: ------------------------------------------------------------------------
2023-10-10T09:51:05.6610981Z 09:51:05.660 INFO: Total time: 9:12.152s
2023-10-10T09:51:05.7434418Z 09:51:05.742 INFO: Final Memory: 27M/100M
2023-10-10T09:51:05.7435742Z 09:51:05.742 INFO: ------------------------------------------------------------------------
2023-10-10T09:51:05.7444467Z ##[error]09:51:05.742 ERROR: Error during SonarScanner execution
java.lang.OutOfMemoryError: Java heap space
	at java.base/java.io.UnixFileSystem.resolve(UnixFileSystem.java:118)
	at java.base/java.io.File.<init>(File.java:263)
	at java.base/java.io.File.listFiles(File.java:1274)
	at org.sonar.plugins.javascript.bridge.TsConfigProvider$LookupTsConfigProvider.tsconfigs(TsConfigProvider.java:176)
	at org.sonar.plugins.javascript.bridge.TsConfigProvider.tsconfigs(TsConfigProvider.java:94)
	at org.sonar.plugins.javascript.bridge.TsConfigProvider.getTsConfigs(TsConfigProvider.java:89)
	at org.sonar.plugins.javascript.bridge.JsTsSensor.analyzeFiles(JsTsSensor.java:109)
	at org.sonar.plugins.javascript.bridge.AbstractBridgeSensor.execute(AbstractBridgeSensor.java:73)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:62)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor$$Lambda$1252/0x00007f9d5c875720.run(Unknown Source)
2023-10-10T09:51:05.7447144Z 09:51:05.742 ERROR: Error during SonarScanner execution
2023-10-10T09:51:05.7447340Z java.lang.OutOfMemoryError: Java heap space
2023-10-10T09:51:05.7447562Z 	at java.base/java.io.UnixFileSystem.resolve(UnixFileSystem.java:118)
2023-10-10T09:51:05.7447786Z 	at java.base/java.io.File.<init>(File.java:263)
2023-10-10T09:51:05.7448146Z 	at java.base/java.io.File.listFiles(File.java:1274)
2023-10-10T09:51:05.7448438Z 	at org.sonar.plugins.javascript.bridge.TsConfigProvider$LookupTsConfigProvider.tsconfigs(TsConfigProvider.java:176)
2023-10-10T09:51:05.7448763Z 	at org.sonar.plugins.javascript.bridge.TsConfigProvider.tsconfigs(TsConfigProvider.java:94)
2023-10-10T09:51:05.7449077Z 	at org.sonar.plugins.javascript.bridge.TsConfigProvider.getTsConfigs(TsConfigProvider.java:89)
2023-10-10T09:51:05.7449381Z 	at org.sonar.plugins.javascript.bridge.JsTsSensor.analyzeFiles(JsTsSensor.java:109)
2023-10-10T09:51:05.7449673Z 	at org.sonar.plugins.javascript.bridge.AbstractBridgeSensor.execute(AbstractBridgeSensor.java:73)
2023-10-10T09:51:05.7449989Z 	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:62)
2023-10-10T09:51:05.7450291Z 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
2023-10-10T09:51:05.7450592Z 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:48)
2023-10-10T09:51:05.7450902Z 	at org.sonar.scanner.sensor.ModuleSensorsExecutor$$Lambda$1252/0x00007f9d5c875720.run(Unknown Source)
2023-10-10T09:51:05.7454942Z ##[error]at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:66)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:48)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:163)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:159)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:130)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.bootstrap.ScannerContainer.doAfterStart(ScannerContainer.java:396)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:57)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:51)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-10-10T09:51:05.7457244Z 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:66)
2023-10-10T09:51:05.7457566Z 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:48)
2023-10-10T09:51:05.7457855Z 	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
2023-10-10T09:51:05.7458158Z 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
2023-10-10T09:51:05.7458454Z 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
2023-10-10T09:51:05.7458734Z 	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:163)
2023-10-10T09:51:05.7459037Z 	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:159)
2023-10-10T09:51:05.7459431Z 	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:130)
2023-10-10T09:51:05.7460140Z 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
2023-10-10T09:51:05.7460522Z 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
2023-10-10T09:51:05.7460819Z 	at org.sonar.scanner.bootstrap.ScannerContainer.doAfterStart(ScannerContainer.java:396)
2023-10-10T09:51:05.7461108Z 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
2023-10-10T09:51:05.7461402Z 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
2023-10-10T09:51:05.7461695Z 	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
2023-10-10T09:51:05.7461983Z 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
2023-10-10T09:51:05.7462281Z 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
2023-10-10T09:51:05.7462546Z 	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:57)
2023-10-10T09:51:05.7462780Z 	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:51)
2023-10-10T09:51:05.7463081Z 	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
2023-10-10T09:51:05.7463361Z 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-10-10T09:51:06.0898375Z Process returned exit code 1
  • Steps to reproduce: Starting the pipeline

We had 9 projects in our solution, and it worked perfectly.
We’ve added a 10th project (AzureFunctions, C#), with about 670 lines of code, and since then we’ve been getting this error.
I’ve tried only analysing the new project, and it worked, also removing the new project, and it still works. So I’m really confused as to why it stops working with just 1 added project.

1 Like

Hello @EdwinBuynamics,

Welcome to the Sonar community, and many thanks for your feedback!

Since adding and removing this 10th project impacts the analysis outcome for some obscure reason, we might be hitting the default memory limit of the JVM here. Could you try to allocate more memory for the JVM? Here is a guide that will help you to do so.

Please let me know if this changes anything.

Thank you,
Yassin

Hi @Yassin,

I’ve since not stopped trying to solve my problem, and yesterday ran the scanner with a memory limit of 4096m.

I’m sure that part worked because the logging stated the following:

INFO: SONAR_SCANNER_OPTS=-Xmx4096m

The code is only about 4k lines in total…

Greetings,
Edwin

Thanks for already trying that out.

Would it be possible to get the full logs of the analysis, ideally the verbose ones? If those contain sensitive data, just obfuscate whatever information should not be shared.

Thank you,
Yassin

Hi Yassin,

Here is the link to the logging:

log-20231012-pr-pipeline-obfuscated.txt (873.4 KB)

Thank you,
Edwin

Hi Yassin,

Thank you Edwin for sharing this issue.

I already have the same issue as Edwin:

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps, using Windows, Microsoft hosted agents
  • Scanner command used when applicable: SonarCloudAnalyze@1
  • Languages of the repository: C#
  • Error observed :
2023-10-12T13:53:02.8234462Z ##[error]ERROR: Error during SonarScanner execution
2023-10-12T13:53:02.8235619Z ERROR: Error during SonarScanner execution
2023-10-12T13:53:02.8240918Z ##[error]java.lang.OutOfMemoryError: Java heap space
2023-10-12T13:53:02.8241611Z java.lang.OutOfMemoryError: Java heap space
2023-10-12T13:53:02.8242267Z ##[error]at java.base/java.util.LinkedHashMap$LinkedKeySet.iterator(LinkedHashMap.java:564)
2023-10-12T13:53:02.8243308Z 	at java.base/java.util.LinkedHashMap$LinkedKeySet.iterator(LinkedHashMap.java:564)
2023-10-12T13:53:02.8244061Z ##[error]at java.base/java.util.Spliterators$IteratorSpliterator.estimateSize(Spliterators.java:1865)
2023-10-12T13:53:02.8248544Z 	at java.base/java.util.Spliterators$IteratorSpliterator.estimateSize(Spliterators.java:1865)
2023-10-12T13:53:02.8249274Z ##[error]at java.base/java.util.Spliterator.getExactSizeIfKnown(Spliterator.java:414)
2023-10-12T13:53:02.8250218Z 	at java.base/java.util.Spliterator.getExactSizeIfKnown(Spliterator.java:414)
2023-10-12T13:53:02.8251036Z ##[error]at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:508)
2023-10-12T13:53:02.8251820Z 	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:508)
2023-10-12T13:53:02.8252537Z ##[error]at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
2023-10-12T13:53:02.8253303Z 	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
2023-10-12T13:53:02.8253904Z ##[error]at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
2023-10-12T13:53:02.8254422Z 	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
2023-10-12T13:53:02.8255117Z ##[error]at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
2023-10-12T13:53:02.8255622Z 	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
2023-10-12T13:53:02.8256172Z ##[error]at java.base/java.util.stream.LongPipeline.reduce(LongPipeline.java:498)
2023-10-12T13:53:02.8256655Z 	at java.base/java.util.stream.LongPipeline.reduce(LongPipeline.java:498)
2023-10-12T13:53:02.8257506Z ##[error]at java.base/java.util.stream.LongPipeline.sum(LongPipeline.java:456)
2023-10-12T13:53:02.8258026Z 	at java.base/java.util.stream.LongPipeline.sum(LongPipeline.java:456)
2023-10-12T13:53:02.8258523Z ##[error]at com.sonar.security.F.D.B.L.A(na:534)
2023-10-12T13:53:02.8258945Z 	at com.sonar.security.F.D.B.L.A(na:534)
2023-10-12T13:53:02.8259518Z ##[error]at com.sonar.security.F.D.B.L.<init>(na:2315)
2023-10-12T13:53:02.8260073Z 	at com.sonar.security.F.D.B.L.<init>(na:2315)
2023-10-12T13:53:02.8260568Z ##[error]at com.sonar.security.F.D.B.L.<init>(na:1957)
2023-10-12T13:53:02.8261119Z 	at com.sonar.security.F.D.B.L.<init>(na:1957)
2023-10-12T13:53:02.8261602Z ##[error]at com.sonar.security.F.D.B.K.<init>(na:1042)
2023-10-12T13:53:02.8262169Z 	at com.sonar.security.F.D.B.K.<init>(na:1042)
2023-10-12T13:53:02.8262645Z ##[error]at com.sonar.security.F.D.D.T.C(na:2318)
2023-10-12T13:53:02.8263173Z 	at com.sonar.security.F.D.D.T.C(na:2318)
2023-10-12T13:53:02.8263860Z ##[error]at com.sonar.security.F.D.D.T.A(na:2022)

PS: This error occured Yesterday.

Thank you,
Amine

Hello @Amine_Ouadrani,

Thank you for your feedback, and welcome to our Sonar community!

Although the failure also highlights a memory issue with the JVM, the logs show it’s coming from a different analyzer, namely the Security analyzer. Therefore, at first glance, I think it’s unrelated to Edwin’s issue that originates from the JavaScript analyzer.

Please create a different thread with your report with the tags sonarcloud, csharp, and security so that the proper experts can take over and investigate your problem :slight_smile:

Thank you,
Yassin

1 Like

Hey @EdwinBuynamics,

Thank you for sharing the full logs!

We might be facing a bug triggering an infinite loop while walking the file system when looking for TSConfig files. Please try to set the property sonar.typescript.tsconfigPaths. You can provide a comma-separated list of TSConfig paths relative to your base directory.

Let’s try this workaround and see whether the problem persists or not.

Regards,
Yassin

Hi @Yassin,

It seems adding sonar.typescript.tsconfigPaths worked to prevent the loop, but now the analyses seems to analyze from a completely different path. (maybe this was the case before adding sonar.typescript.tsconfigPaths of course)

First I was getting ~2000 issues, because it was analyzing everything, including nuget packages. After adding sonar.sources=src/ and sonar.tests=tests/ that was resolved, but the paths still aren’t matching up.
Issues in SonarCloud (and in comments in Azure DevOps) now have a path starting with home/vsts/work/1/s/src/ instead of just src/.
SonarCloud also gives me a warning: SCM provider autodetection failed. Please use "sonar.scm.provider" to define SCM of your project, or disable the SCM Sensor in the project settings. This warning doesn’t seem strange if it can’t match up the paths correctly with git.

Do you know why the paths aren’t matching up anymore? How can I fix this?

Thank you,
Edwin

Hello @EdwinBuynamics,

The property I suggested you set for TSConfigs should not impact in any way the path issue you are now facing. I am not sure why the paths aren’t matching up anymore, unfortunately. However, I will ping SonarCloud experts so that they can assist you in that matter.

Regarding the warnings about SCM, those are just pointing out that the scanner is not able to collect data from your configured source code management like git, if any. If they are bothering you and you don’t care about them, you can just disable them with sonar.scm.disabled=true.

Yassin

Hi Edwin,

We try to keep it to one topic per thread. Otherwise it can get messy, fast. Would you mind creating a new thread with all your details for this question of paths?

 
Thx,
Ann

Hi @ganncamp,

From my perspective the solution provided by Yassin Kammoun is only a solution to a sympton that started when the paths got messed up.
Why?
Because it seems weird that I have to set the tsconfigPaths when the new project doesn’t contain any typescript. (it’s a C# Azure Function).

I think we’re still on the same topic…

Edwin

Looks like I’ve found the solution: the issue was with the added Azure Function project.

Because of the added Azure Function project the paths got messed up due to a bug in the SonarScanner, and that probably caused a second bug to trigger an infinite loop. Setting the sonar.typescript.tsconfigPaths solved the second bug, but not the first bug.

The solution was adding sonar.projectBaseDir=$(Agent.BuildDirectory)/s/ to the extraProperties of the pipeline task. This is a work around for the first bug, so the second bug doesn’t get triggered.

1 Like

Hello @EdwinBuynamics,

I’m glad you worked through this. Sorry for the inconvenience caused by that bug, hopefully, we’ll get a fix released soon.

Best regards,

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