Skip to content

StackOverFlow in CI runner with PrepJSInterop and test_java8 #18334

Closed
@bishabosha

Description

@bishabosha

Compiler version

ec64ae0
See https://github.com/lampepfl/dotty/actions/runs/5746108750
prompted by failed nightly build #18333

There was a stack overflow error when running PrepJSInterop on tests/run/StringConcat.scala with java 8 (specifically dotty.tools.dotc.ScalaJSCompilationTests.runScalaJS)

Minimized code

// tests/run/StringConcat.scala
@main def Test() = {

  // This should generally obey 15.18.1. of the JLS (String Concatenation Operator +)
  def concatenatingVariousTypes(): String = {
    val str: String = "some string"
    val sb: StringBuffer = new StringBuffer("some stringbuffer")
    val cs: CharSequence = java.nio.CharBuffer.allocate(50).append("charsequence")
    val i: Int = 123456789
    val s: Short = 345
    val b: Byte = 12
    val z: Boolean = true
    val f: Float = 3.5
    val j: Long = 98762147483647L
    val d: Double = 3.1415d

    "String " + str + "\n" +
      "StringBuffer " + sb + "\n" +
      "CharSequence " + cs + "\n" +
      "Int " + i + "\n" +
      "Short " + s + "\n" +
      "Byte " + b + "\n" +
      "Boolean " + z + "\n" +
      "Float " + f + "\n" +
      "Long " + j + "\n" +
      "Double " + d + "\n"
  }
  // The characters `\u0001` and `\u0002` play a special role in `StringConcatFactory`
  def concatenationInvolvingSpecialCharacters(): String = {
    val s1 = "Qux"
    val s2 = "Quux"

    s"Foo \u0001 $s1 Bar \u0002 $s2 Baz"
  }
  // Concatenation involving more than 200 elements
  def largeConcatenation(): String = {
    val s00 = "s00"
    val s01 = "s01"
    val s02 = "s02"
    val s03 = "s03"
    val s04 = "s04"
    val s05 = "s05"
    val s06 = "s06"
    val s07 = "s07"
    val s08 = "s08"

    // 24 rows follow
    ((s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n") +
      (s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n")) +
      ((s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n") +
      (s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n" +
      s00 + "," + s01 + "," + s02 + "," + s03 + "," + s04 + "," + s05 + "," + s06 + "," + s07 + "," + s08 + "\n"))
  }
  println("----------")
  println(concatenatingVariousTypes())
  println("----------")
  println(concatenationInvolvingSpecialCharacters())
  println("----------")
  println(largeConcatenation())
  println("----------")
}

Output (click arrow to expand)

[info] Test dotty.tools.dotc.ScalaJSCompilationTests.runScalaJS started

  unhandled exception while running prepjsinterop on tests/run/StringConcat.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/lampepfl/dotty/issues/new/choose

     while compiling: tests/run/StringConcat.scala
        during phase: prepjsinterop
                mode: Mode(ImplicitsEnabled,ReadPositions)
     library version: version 2.13.10
    compiler version: version 3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped-git-ec64ae0
            settings: -Xsemanticdb true -Xunchecked-java-output-version 8 -Xverify-signatures true -Ycheck List(all) -Yforce-sbt-phases true -Yno-deep-subtypes true -Yno-double-bindings true -classpath /root/.cache/coursier/v1/https/scala-webapps.epfl.ch/artifactory/central/org/scala-lang/scala-library/2.13.10/scala-library-2.13.10.jar:/__w/dotty/dotty/library/../out/bootstrap/scala3-library-bootstrapped/scala-3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-library_3-3.4.0-RC1-bin-SNAPSHOT.jar:/root/.cache/coursier/v1/https/scala-webapps.epfl.ch/artifactory/central/org/scala-js/scalajs-javalib/1.12.0/scalajs-javalib-1.12.0.jar:/root/.cache/coursier/v1/https/scala-webapps.epfl.ch/artifactory/central/org/scala-js/scalajs-library_2.13/1.12.0/scalajs-library_2.13-1.12.0.jar:/__w/dotty/dotty/library-js/../out/bootstrap/scala3-library-bootstrappedJS/scala-3.4.0-RC1-bin-SNAPSHOT-nonbootstrapped/scala3-library_sjs1_3-3.4.0-RC1-bin-SNAPSHOT.jar:out/runScalaJS/run/StringConcat -color never -d out/runScalaJS/run/StringConcat -indent true -pagewidth 120 -scalajs true
java.lang.StackOverflowError

                tree: EmptyTree
       tree position: :<unknown>
           tree type: <notype>
              symbol: val <none>
           call site: package <root> in module class <root>

  == Source file context for tree position ==


	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1516)
	at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transformStatOrExpr(PrepJSInterop.scala:402)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transform(PrepJSInterop.scala:130)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1523)
	at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transformStatOrExpr(PrepJSInterop.scala:402)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transform(PrepJSInterop.scala:130)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1529)
	at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transformStatOrExpr(PrepJSInterop.scala:402)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transform(PrepJSInterop.scala:130)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1523)
	at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transformStatOrExpr(PrepJSInterop.scala:402)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transform(PrepJSInterop.scala:130)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1529)
	at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transformStatOrExpr(PrepJSInterop.scala:402)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transform(PrepJSInterop.scala:130)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1523)
	at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transformStatOrExpr(PrepJSInterop.scala:402)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transform(PrepJSInterop.scala:130)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1529)
	at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transformStatOrExpr(PrepJSInterop.scala:402)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transform(PrepJSInterop.scala:130)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1523)
	at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transformStatOrExpr(PrepJSInterop.scala:402)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transform(PrepJSInterop.scala:130)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1529)
	at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transformStatOrExpr(PrepJSInterop.scala:402)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transform(PrepJSInterop.scala:130)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1523)
	at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transformStatOrExpr(PrepJSInterop.scala:402)
	at dotty.tools.dotc.transform.sjs.PrepJSInterop$ScalaJSPrepJSInteropTransformer.transform(PrepJSInterop.scala:130)
	at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1529)
	at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:49)
	at 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions