-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
area:transformitype:bugitype:crashstat:cannot reproducestat:needs minimizationNeeds a self contained minimizationNeeds a self contained minimization
Description
On my github CI, I consistently see compiler crashes during staging. The code itself has been hard to minimize due to the crash not happening locally. I tried a variety of stack sizes, but once I reach -Xss512k
other parts of the code fail to compile due to non-trivial inlining.
Compiler version
- 3.6.3
Minimized code
The code is very similar to this file: https://github.com/getkyo/kyo/blob/main/kyo-examples/jvm/src/main/scala/examples/ledger/api/Endpoints.scala
It uses kyo-direct
. The code is private, but happy to share privately with maintainers.
Output (click arrow to expand)
error] ## Exception when compiling 3 sources to /home/runner/work/winedb/winedb/backend/target/scala-3.6.3/classes
[error] java.lang.StackOverflowError
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1524)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1531)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1537)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1643)
[error] scala.collection.immutable.List.mapConserve(List.scala:473)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1643)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:55)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:34)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1605)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:43)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1289)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1289)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1294)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1551)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:43)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:24)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1600)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:43)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1289)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1289)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1294)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1551)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:43)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:24)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1545)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1571)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1531)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1539)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1537)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock$$anonfun$1$$anonfun$1(tpd.scala:1294)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1276)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1289)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1294)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1551)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:43)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:24)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock$$anonfun$1$$anonfun$1(tpd.scala:1294)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1276)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1289)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1294)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1551)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:43)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:24)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1545)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1571)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1531)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1539)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1537)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock$$anonfun$1$$anonfun$1(tpd.scala:1294)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1276)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1289)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1294)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1551)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:43)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:24)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock$$anonfun$1$$anonfun$1(tpd.scala:1294)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1276)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1289)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1294)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1551)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:43)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:24)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1545)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1571)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1531)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1539)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1537)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock$$anonfun$1$$anonfun$1(tpd.scala:1294)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1276)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1289)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1294)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1551)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:43)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:24)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:43)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:24)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1600)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:43)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1289)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1289)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1294)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1551)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:43)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:24)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1545)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1571)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1531)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1539)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1537)
[error] dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error] dotty.tools.dotc.staging.TreeMapWithStages.transform(TreeMapWithStages.scala:46)
[error] dotty.tools.dotc.staging.CrossStageSafety.transform(CrossStageSafety.scala:123)
[error] dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock$$anonfun$1$$anonfun$1(tpd.scala:1294)
Metadata
Metadata
Assignees
Labels
area:transformitype:bugitype:crashstat:cannot reproducestat:needs minimizationNeeds a self contained minimizationNeeds a self contained minimization
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
WojciechMazur commentedon Mar 3, 2025
-Xss512k
is ~ 0.5MB per thread, the JVM default is 1MB. The Scala compiler is not multithreading-heavy so typically you'd want to have bigger stack size, especially in case on non trivial code, like multi-level inlines.The kyo is using lots of inlining and non trivial typing which might require a bigger stack size for the compiler.
I believe that instead of StackOverflowError the efforts should focus on dealing with the inlining.
Gedochao commentedon Mar 3, 2025
@jchyb @dwijnand Can you think of any advice, how to help with minimising/reproducing this?
@hearnadam it's hard to tell when we'll have the capacity to spend time on this in the maintenance team. When someone is available, we may reach out, but it'd be best to try to minimise this on your side, at least partially.
jchyb commentedon Mar 3, 2025
Looking through the stack trace, nothing seems out of the ordinary - it just walks thought the program tree. I am wondering if perhaps somehow a different code is generated by Kyo locally and in the CI, as unlikely as that sounds. You can try running with the
-Xcheck-macros
option to check if the code generated by Kyo is correct. Otherwise I agree with @WojciechMazur that the issue might be with a too small of a stack size.seroperson commentedon Jul 3, 2025
I guess I faced the same issue here bot4s/telegram#383 (comment) during migration to Scala 3. It occurs randomly: sometimes it compiles, but most of time it crashes.
Stacktrace looks very similar:
Details
seroperson commentedon Jul 6, 2025
This bug continuously (most of the time) appears on bot4s/telegram@e1325b4 commit even locally. The file which fails is: CirceDecoders.scala with a lot of automatically derived circe decoders. After I splitted this file and moved decoders to corresponding models, and then did the same to the similar
CirceEncoders.scala
file, this bug being unreproducible locally. After such splitting everything went good locally, but it was still reproducible on CI too during processing Message.scala file (which is heavy enough, there are around 60 fields and auto-derived codec). I implementedEncoder
/Decoder
manually for this class and finally build went green.Here is a build which failed on
Messages.scala
processing. And stacktrace:Details
WojciechMazur commentedon Jul 7, 2025
I've tried to reproduce it locally multiple times, but on my machine it always worked correctly with different versions of Scala 3 and JDK versions - MacOS M1 aarch64.
However what's interesting the StackOverflowErrror was triggered the first time I've tried to build on x86_64 Linux with JDK 11 (using gitpod). I have no idea why it platform might affect it, but seems like a worthy note when trying to minimize the issue.
What's also interesting in case of bot4s/telegram is fact that increasing -Xss to 5M (from default 1M) has not fixed the issue, it suggests there might be an actual problem in the compiler leading to infinite recursive call loop.
When trying to reproduce the issue outside the repo (and the external dependencies) I've only managed to get StackOverflowErrors during
parser
phase due to gargantuan for-comprehension block inspired byMessage
circe decoder from the repo.When running with
-Yprofile-trace
I've once seen a graceful error, probably caused by exceeding recursive inline depth, but I don't remember it exactly. With profiling enabled there might be some small differences in symbols lookup (e.g. order) which could explain it.Anyway I've not yet managed to obtain a reliable reproducer. The original repo was indeed crashing in gitpod, but there was a period in which is started to successfully compile (every compilation test involved cleaning the build tool result and running a fresh compilation)
seroperson commentedon Jul 7, 2025
My environment, just in case (WSL + JDK 17):