0

I am compiling a Scala project with maven and it gives me a stackoverflow error on 2 different build servers, but locally there's no such thing.

The Xss parameter locally (on a macbook air with the m1 processor) is 1024 kilobytes. On the server it only works when I give it 25 gigabytes.

What could this be?

Error log:

+[20:26:11]+[Step 1/1] [ERROR] error: java.lang.StackOverflowError
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.typechecker.Contexts$Context.makeSilent(Contexts.scala:515)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:675)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4524)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4580)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5343)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5360)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:698)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:5472)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:5480)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.transform.Erasure$Eraser.adaptMember(Erasure.scala:644)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:698)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
+[20:26:11]+[Step 1/1] [INFO] at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
pavel_orekhov
  • 1,657
  • 2
  • 15
  • 37
  • 2
    Worth reading: [“Why is the max recursion depth I can reach non-deterministic?”](https://stackoverflow.com/q/27043922/2711488) I wouldn’t be surprised if Scala has lots of recursion (and nested constructs) and is more sensitive to it. Since such languages usually provide their own solutions to mitigate such issues (read: inlining on the bytecode level, etc), results might also depend on their configuration. Since you mentioned Maven, there’s also the possibility that the problems are caused by a dependency that is already built on your computer but not the servers. – Holger Nov 15 '21 at 14:36
  • 2
    StackOverflow in Typer phase of `scalac` compilation is usually a result of a type class derivation. Recursive Shapeless-based derivations is a bit more prone to it than Magnolia-based. Since recursive resolution of implicits was implemented with recursive calls in `scalac` codebases heavy with compile time reflection might need larger _stack_'s. (But not necessarily 25GB, sbt-extras use 2MB as default) – Mateusz Kubuszok Nov 15 '21 at 16:26
  • 2
    Different JIT compilers (broadly interpreted) will make different decisions around what they can inline, and a consequence of their inlining decision can be performing on-stack replacement (which increases the size of a stack frame by using the stack to allocate objects instead of the heap). Your build server is most likely x86 and your M1 Mac is an ARM, so they're definitely using different JIT compilers. – Levi Ramsey Nov 15 '21 at 16:49

0 Answers0