scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Stack Overflow Exception in typer #9696

Open scabug opened 8 years ago

scabug commented 8 years ago

typer error when trying to compile test. // Stripped-down version is available at https://github.com/rssh/scala-gopher/tree/scala-2.11.8-so-in-compiler

for reproduce:

git clone git@github.com:rssh/scala-gopher.git --branch scala-2.11.8-so-in-compiler
cd scala-gopher
sbt clean compile test
 version[info] Compiling 1 Scala source to /Users/rssh/work/oss/scala-gopher/target/scala-2.11/test-classes...
java.lang.StackOverflowError
    at scala.tools.nsc.typechecker.ContextErrors$TyperContextErrors$TyperErrorGen$.MacroExpansionException$lzycompute(ContextErrors.scala:757)
    at scala.tools.nsc.typechecker.ContextErrors$TyperContextErrors$TyperErrorGen$.MacroExpansionException(ContextErrors.scala:757)
    at scala.tools.nsc.typechecker.Macros$MacroExpander$$anonfun$expand$1.apply(Macros.scala:599)
    at scala.tools.nsc.typechecker.Macros$MacroExpander$$anonfun$expand$1.apply(Macros.scala:573)
    at scala.tools.nsc.Global.withInfoLevel(Global.scala:211)
    at scala.tools.nsc.typechecker.Macros$MacroExpander.expand(Macros.scala:572)
    at scala.tools.nsc.typechecker.Macros$MacroExpander.apply(Macros.scala:560)
    at scala.tools.nsc.typechecker.Macros$class.standardMacroExpand(Macros.scala:724)
    at scala.tools.nsc.Global$$anon$1.standardMacroExpand(Global.scala:462)
    at scala.tools.nsc.typechecker.AnalyzerPlugins$$anon$10.default(AnalyzerPlugins.scala:400)
    at scala.tools.nsc.typechecker.AnalyzerPlugins$$anon$10.default(AnalyzerPlugins.scala:397)
    at scala.tools.nsc.typechecker.AnalyzerPlugins$class.invoke(AnalyzerPlugins.scala:369)
    at scala.tools.nsc.typechecker.AnalyzerPlugins$class.pluginsMacroExpand(AnalyzerPlugins.scala:397)
    at scala.tools.nsc.Global$$anon$1.pluginsMacroExpand(Global.scala:462)
    at scala.tools.nsc.typechecker.Macros$class.macroExpand(Macros.scala:717)
    at scala.tools.nsc.Global$$anon$1.macroExpand(Global.scala:462)
    at scala.tools.nsc.typechecker.Typers$Typer.vanillaAdapt$1(Typers.scala:1111)
    at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1166)
    at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5410)
    at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
    at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
    at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
    at scala.tools.nsc.typechecker.Typers$Typer.typedArg(Typers.scala:3164)
    at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedArgToPoly$1(Typers.scala:3515)
    at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$75.apply(Typers.scala:3523)
    at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$75.apply(Typers.scala:3523)
    at scala.reflect.internal.util.Collections$class.map2(Collections.scala:79)
    at scala.reflect.internal.SymbolTable.map2(SymbolTable.scala:16)
    at scala.tools.nsc.typechecker.Typers$Typer.handlePolymorphicCall$1(Typers.scala:3523)
    at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3534)
    at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4546)
    at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4580)
    at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5343)
    at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5360)
    at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
    at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
    at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
    at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
    at scala.tools.nsc.typechecker.Typers$Typer.typedTyped$1(Typers.scala:5111)
    at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5346)
    at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5360)
    at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
    at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
    at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
    at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
    at scala.tools.nsc.typechecker.Macros$DefMacroExpander.typecheck$1(Macros.scala:635)
    at scala.tools.nsc.typechecker.Macros$DefMacroExpander.onSuccess(Macros.scala:643)
    at scala.tools.nsc.typechecker.Macros$MacroExpander$$anonfun$expand$1.apply(Macros.scala:586)
    at scala.tools.nsc.typechecker.Macros$MacroExpander$$anonfun$expand$1.apply(Macros.scala:573)
    at scala.tools.nsc.Global.withInfoLevel(Global.scala:211)
    at scala.tools.nsc.typechecker.Macros$MacroExpander.expand(Macros.scala:572)
    at scala.tools.nsc.typechecker.Macros$MacroExpander.apply(Macros.scala:560)
    at scala.tools.nsc.typechecker.Macros$class.standardMacroExpand(Macros.scala:724)
    at scala.tools.nsc.Global$$anon$1.standardMacroExpand(Global.scala:462)
    at scala.tools.nsc.typechecker.AnalyzerPlugins$$anon$10.default(AnalyzerPlugins.scala:400)
    at scala.tools.nsc.typechecker.AnalyzerPlugins$$anon$10.default(AnalyzerPlugins.scala:397)
    at scala.tools.nsc.typechecker.AnalyzerPlugins$class.invoke(AnalyzerPlugins.scala:369)
    at scala.tools.nsc.typechecker.AnalyzerPlugins$class.pluginsMacroExpand(AnalyzerPlugins.scala:397)
    at scala.tools.nsc.Global$$anon$1.pluginsMacroExpand(Global.scala:462)
    at scala.tools.nsc.typechecker.Macros$class.macroExpand(Macros.scala:717)
    at scala.tools.nsc.Global$$anon$1.macroExpand(Global.scala:462)
    at scala.tools.nsc.typechecker.Typers$Typer.vanillaAdapt$1(Typers.scala:1111)
    at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1166)
    at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5410)
    at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
scabug commented 8 years ago

Imported From: https://issues.scala-lang.org/browse/SI-9696?orig=1 Reporter: ruslan shevchenko (rssh) Affected Versions: 2.11.8 See #9002

scabug commented 8 years ago

ruslan shevchenko (rssh) said: btw, this can be reincarnation of #9002

scabug commented 8 years ago

ruslan shevchenko (rssh) said: need check, how they are linked.

scabug commented 8 years ago

@janekdb said: I started seeing this exception a few days ago. Increasing the stack size avoids the problem.

This is my Maven configuration with the stack size specified at a value that fixes the problem.

||Value||Build successes out of 10 runs|| |1024|0| |2048|10|

      <!-- Execute scalac before javac to support joint compilation. -->
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>3.2.2</version>
        <configuration>
          <args>
            <!--
            <arg>-verbose</arg>
            <arg>-unchecked</arg>
            <arg>-explaintypes</arg>
            -->
            <arg>-deprecation</arg>
          </args>
          <displayCmd>true</displayCmd>
          <jvmArgs>
            <jvmArg>-Xss2048K</jvmArg>
          </jvmArgs>
        </configuration>
        <executions>
          <!--
            add-source is not required. java and scala source directories are included by default.
            Scala sources can be located in either directory.
            Java sources must be located in the java source directory.
          . -->
          <!--
          <execution>
          <id>scala-add-source</id>
          <goals>
            <goal>add-source</goal>
          </goals>
          <configuration>
            <sourceDir>${project.build.sourceDirectory}/../scala</sourceDir>
            <testSourceDir>${project.build.testSourceDirectory}/../scala</testSourceDir>
          </configuration>
          </execution>
          -->
          <execution>
            <id>scala-compile</id>
            <phase>process-resources</phase>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
          <execution>
            <id>scala-test-compile</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

For me it's not a bug but it would be useful to have some tuning guidance logged when this happens.