Omer van Kloeten
Omer van Kloeten

Reputation: 11980

StackOverflowError While in SBT's Compile

While building (either with compile or test:compile), I get this error:

[info] [specializing CorrelationDal.scala]
[error] {file:/home/bamboo/.../}batch/compile:compile: java.lang.StackOverflowError
[error] Total time: 20 s, completed Feb 28, 2012 7:32:08 AM

As you can tell, I've set the '-verbose' option in the scalacOption key.

I decided to try and give the compilation process a larger stack size using:

(fork := true) ++ (javaOptions += "-Xss4G")

But that changed nothing.

I've tried to inspect the changes I made to CorrelationDal.scala and made some attempts at relaxing the amount of inference it needs to do (explicitly noting types, removing chained creation of iterables, etc.), but I can't really tell which were the culprits without internal understanding of the Scala compiler.

Does anyone have any clues as to how to get to the heart of the issue?

Upvotes: 1

Views: 3826

Answers (3)

cnxiaoma
cnxiaoma

Reputation: 61

After I add -Xss2M in the sbt script file, it is OK.

Upvotes: 6

Omer van Kloeten
Omer van Kloeten

Reputation: 11980

Turns out this is an issue with string concatenation. If you concatenate too many strings, like this:

"string" + "other string" + variable + "string" + ...

You'll get to this. I assume this is because of the type inferrence mechanism in the compiler that just tries too hard. Hope it will be fixed in a future version (I'm using 2.9.1...)

Upvotes: 3

Daniel C. Sobral
Daniel C. Sobral

Reputation: 297265

That parameter is meaningless -- you are not running, just compiling.

You have to change the stack size for SBT itself. Just edit the sbt script and change it.

Upvotes: 1

Related Questions