Random compiler stack overflow
See original GitHub issueCompiler version
3.1.0
Description
Once or twice a week, dotty crashes with stack overflow when I make a clean
compile
. Looks like it’s
stuck in a loop:
[error] ## Exception when compiling 552 sources to /home/fg/dev/spider6/core/target/scala-3.1.0/classes
[error] java.lang.StackOverflowError
[error] dotty.tools.dotc.transform.Constructors.dotty$tools$dotc$transform$Constructors$$noDirectRefsFrom(Constructors.scala:117)
[error] dotty.tools.dotc.transform.Constructors$intoConstr$1$.transform(Constructors.scala:160)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1396)
[error] dotty.tools.dotc.transform.Constructors$intoConstr$1$.transform(Constructors.scala:160)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1390)
[error] dotty.tools.dotc.transform.Constructors$intoConstr$1$.transform(Constructors.scala:160)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1396)
[error] dotty.tools.dotc.transform.Constructors$intoConstr$1$.transform(Constructors.scala:160)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1390)
[error] dotty.tools.dotc.transform.Constructors$intoConstr$1$.transform(Constructors.scala:160)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1396)
[error] dotty.tools.dotc.transform.Constructors$intoConstr$1$.transform(Constructors.scala:160)
this continues on for 600++ lines.
Interestingly, if I immediately redo the clean / compile cycle inside the same SBT session, without changing anything, it works.
My .sbtopts
settings, although seeing the stack trace I don’t think the problem is there:
cat .sbtopts
-J-Xmx4g
-J-XX:ReservedCodeCacheSize=1g
-J-XX:MaxMetaspaceSize=2g
The full sbt session is bug2.txt
Sorry for the subpar report 🙄️
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
C++ (seemingly) Random Compiler Errors
For a variable to be able to be used as an array size, it needs to be a constant expression. This is denoted...
Read more >Buffer overflow protection
Buffer overflow protection is any of various techniques used during software development to enhance the security of executable programs by detecting buffer ...
Read more >What function generates random numbers in a compiled ...
There are two cases, the first one is just plain Compile , the second one uses the option: CompilationTarget -> "C" , which...
Read more >Stack-Based Buffer Overflow Attacks: Explained
Since most stack overflow attacks involved overflowing one data location and writing to another, the compiler placed a sacrificial known value ...
Read more >Stack Canaries – Gingerly Sidestepping the Cage
The Linux C compiler gcc currently contains the Stack Smashing protector, which will introduce a random canary if /dev/urandom is available.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Agree 100% on minimisation… This is a difficult bug to catch: 1 - appears at random: only once / twice in a week, then nothing for one or two months, then comes back. 2 - immediately disappears: after the crash, if I say “compile” to sbt, even without “clean”, the stack overflow don’t shows again 3 - no indication from compiler on which line / which file, made it crash. 4 - the whole program is 120,000 lines long
Non objective feeling This stack overflow crash “smells” like improper sharing of memory between multiple threads. Need lots of code to compile, multiple sub-projects (–> concurrent running threads in dotty), to show up only in the unlikely event of two processors running a same piece of code with some mutable shared state.
Now I will make a “dotty stress test” project:
sbt "; clean; compile"
on my customer project, let it run in background until the bug comes back.Stack allocation option is
-J-Xss2m
, that’s the first thing they say on Scala 2. That is, stack to sbt. In case the looping is transiently finite.There is also a bug fix in that area of code, who knows if it would change this behavior.