Sonar-scanner java.io.IOException: In-memory buffer limit exceeded

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube: 7.5.0 Developer Edition
    sonar-scanner: 3.2.0.1227 (on Mac Mojave)
  • what are you trying to achieve
    Run a code coverage analysis of an iOS app
  • what have you tried so far to achieve this
    When running sonar-scanner I receive the following error:
09:24:32.012 ERROR: ERROR: Exception caught while accessing pack file /private/var/jenkins/workspace/<project>/.git/objects/pack/pack-3929fde6de9a3402293ee9f8c69ad126e83cd46c.pack, the pack file might be corrupt, {1}. Caught {2} consecutive errors while trying to read this pack.
java.io.IOException: In-memory buffer limit exceeded
	at org.eclipse.jgit.internal.storage.file.PackFile.load(PackFile.java:856)
	at org.eclipse.jgit.internal.storage.file.PackFile.get(PackFile.java:275)
	at org.eclipse.jgit.internal.storage.file.ObjectDirectory.openPackedObject(ObjectDirectory.java:471)
	at org.eclipse.jgit.internal.storage.file.ObjectDirectory.openPackedFromSelfOrAlternate(ObjectDirectory.java:429)
	at org.eclipse.jgit.internal.storage.file.ObjectDirectory.openObject(ObjectDirectory.java:420)
	at org.eclipse.jgit.internal.storage.file.WindowCursor.open(WindowCursor.java:159)
	at org.eclipse.jgit.revwalk.RevWalk.getCachedBytes(RevWalk.java:903)
	at org.eclipse.jgit.revwalk.RevCommit.parseHeaders(RevCommit.java:155)
	at org.eclipse.jgit.revwalk.RevWalk.parseHeaders(RevWalk.java:1018)
	at org.eclipse.jgit.blame.BlameGenerator.processOne(BlameGenerator.java:604)
	at org.eclipse.jgit.blame.BlameGenerator.next(BlameGenerator.java:499)
	at org.eclipse.jgit.blame.BlameResult.computeAll(BlameResult.java:239)
	at org.eclipse.jgit.blame.BlameGenerator.computeBlameResult(BlameGenerator.java:453)
	at org.eclipse.jgit.api.BlameCommand.call(BlameCommand.java:231)
	at org.sonarsource.scm.git.JGitBlameCommand.blame(JGitBlameCommand.java:98)
	at org.sonarsource.scm.git.JGitBlameCommand.lambda$null$0(JGitBlameCommand.java:69)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:290)
	at java.base/java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:746)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)

I have tried setting SONAR_SCANNER_OPTS to various values, from -Xmx512m all the way to -Xmx4096m with the same result.

Is there another limit or timeout at play during a sonar-scanner run I can look at to resolve the error?

I resolved the issue by installing more memory on the Mac.

Hi,
The error is specific to the library used to handle git (JGit), it doesn’t necessarily mean you ran out of memory. You resolved the problem just by installing more memory in your computer?

Yes, adding memory to the Mac resolved this specific issue. We are running our CI/CD pipeline on MacStadium’s “cloud” platform, a Mac Pro with VMWare ESX. The Mac builders are running as VMs with 4 GB RAM. This error went away when we increased the RAM to 6 GB.