Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion failure in isAnonymousOrLocalClass #8900

Closed
scabug opened this issue Oct 12, 2014 · 16 comments
Closed

Assertion failure in isAnonymousOrLocalClass #8900

scabug opened this issue Oct 12, 2014 · 16 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Oct 12, 2014

When using the 2.11.3 version that is currently on Maven Central or the most recent SNAPSHOT, I get an assertion failure when compiling the latest development version of our Kiama library. The build log is in the attached file, but the stack trace starts:

at scala.tools.nsc.backend.jvm.BCodeAsmCommon.isAnonymousOrLocalClass(BCodeAsmCommon.scala:35)
at scala.tools.nsc.backend.jvm.GenASM$JBuilder.scala$tools$nsc$backend$jvm$GenASM$JBuilder$$outerName$1(GenASM.scala:686)
at scala.tools.nsc.backend.jvm.GenASM$JBuilder.addInnerClasses(GenASM.scala:722)
at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genClass(GenASM.scala:1341)
at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.emitFor$1(GenASM.scala:197)
at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.run(GenASM.scala:203)
at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1338)
at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1325)
@scabug
Copy link
Author

scabug commented Oct 12, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8900?orig=1
Reporter: Tony Sloane (asloane)
Affected Versions: 2.11.3
Attachments:

  • log.txt (created on Oct 12, 2014 5:42:35 AM UTC, 81587 bytes)

@scabug
Copy link
Author

scabug commented Oct 12, 2014

Tony Sloane (asloane) said:
Forgot to say explicitly that the relevant version is the latest in this repo:

hg clone https://code.google.com/p/kiama/

The log mentions org.kiama.example.lambda2.LambdaTree so I presume the crash is triggered there somewhere, but I haven't narrowed it down yet.

@scabug
Copy link
Author

scabug commented Oct 12, 2014

Tony Sloane (asloane) said:
The relevant commit seems to be

scala/scala@63207e1

@scabug
Copy link
Author

scabug commented Oct 12, 2014

@retronym said:
@lrytz We're getting a false positive from isDelambdafyFunction. The symbol name in question is LambdaTests$$anonfun$org$kiama$example$lambda2$LambdaTests$$canons$1$1. I don't have a smaller reproduction yet.

@scabug
Copy link
Author

scabug commented Oct 12, 2014

@gkossakowski said:
Tony, can this issue be reproduced with released version of Kiama?

@scabug
Copy link
Author

scabug commented Oct 12, 2014

@Sciss said:
Are the labels correct? It says affects 2.10.3 / fixed 2.10.4. Should it be 2.11.3?

@scabug
Copy link
Author

scabug commented Oct 12, 2014

@lrytz said:
Hi @retronym, [~asloane]. The failing file is library/src/org/kiama/example/lambda2/LambdaTests.scala. As a reduced version, replace the content of the file by the follwing, it triggers the same error.

package org.kiama
package example.lambda2

import org.kiama.util.RegexParserTests
import scala.language.experimental.macros

class LambdaTests {
    import org.kiama.rewriting.Strategy
    def rule[T] (f : PartialFunction[T, T]) : Strategy = ???
    case class Var(x: Int)
    def canon = {
        def canons: Strategy = rule[Var] { case Var (n) => Var (n) } + canons
    }
}

The fishy thing is that Strategy.+ is a macro, and I could not reproduce the failure without the macro call. So it's possible that the assertion doesn't fail on compiler-generated code.

However, the implementation of isDelambdafyFunction (as well as isAnonymousFunction) is not robust at all against false positives:

    final def isAnonymousFunction = isSynthetic && (name containsName tpnme.ANON_FUN_NAME)
    final def isDelambdafyFunction = isSynthetic && (name containsName tpnme.DELAMBDAFY_LAMBDA_CLASS_NAME)

So an assert(!sym.isDelambdafyFunction) is unsafe. I think for now we should just remove the assertion, longer term there should be a better implementation of the above.

@scabug
Copy link
Author

scabug commented Oct 12, 2014

@lrytz said:
scala/scala#4049

@scabug
Copy link
Author

scabug commented Oct 12, 2014

Tony Sloane (asloane) said:
Grzegorz: yes, the same problem occurs with Kiama 1.7.0 which is the most recent release.

@scabug
Copy link
Author

scabug commented Oct 12, 2014

@gkossakowski said:
Tony, would you be interested in adding Kiama 1.7.0 to the community build that we use to test Scala compiler? Given that you guys found a regression that none of 77 projects that are already there caught, it would be great to welcome you to the family!

@scabug
Copy link
Author

scabug commented Oct 12, 2014

Tony Sloane (asloane) said:
Grzegorz, yes, no objections from me if you want to include Kiama in the community build. Is there anything I need to do?

@scabug
Copy link
Author

scabug commented Oct 13, 2014

@gkossakowski said:
Tony, I was wondering if you could help with adding Kiama to community build. Adding a project to community build very often requires understanding of project's build so it's best done by project maintainers. Also, we are trying to spread the effort amongst community members so we can Scale the whole process to 100+ projects.

@scabug
Copy link
Author

scabug commented Oct 13, 2014

@sjrd said:
This is also hit in Scala.js (see scala-js/scala-js#1147).

In the case of Scala.js, I can tell you that it's not generated by a macro, because there's no macro in the Scala.js repository. The failing project is the test suite, which is not compiled with -Ydelambdafy:method. There is however, on the classpath of that compilation, another project which is compiled with -Ydelambdafy:method (the test-bridge).

@scabug
Copy link
Author

scabug commented Oct 13, 2014

Tony Sloane (asloane) said:
Grzegorz, ok, I'll look into adding Kiama to the community build. Shouldn't be a problem.

@scabug
Copy link
Author

scabug commented Oct 20, 2014

Tony Sloane (asloane) said:
Grzegorz, on the community build question, it appears that only git and svn are supported by dbuild at the moment. This limits what I can do since Kiama is in a Mercurial repository. I've added a ticket over at the dbuild tracker to flag this issue:

lightbend-labs/dbuild#146.

@scabug
Copy link
Author

scabug commented Oct 20, 2014

@gkossakowski said (edited on Oct 20, 2014 12:50:21 PM UTC):
Oh, it's a bummer we can't add Kiama to community build right away! Thanks for opening an issue against dbuild so we have that limitation documented. I hope dbuild can learn how to read Mercurial repos at some point.

Here's link to PR that fixes the original issue reported in this ticket: scala/scala#4049

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants