Skip to content

Assertion failure in isAnonymousOrLocalClass #8900

Closed

Description

@scabug

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)

Activity

  1. scabug commented on Oct 12, 2014

    @scabug
    Author

    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)
  2. scabug commented on Oct 12, 2014

    @scabug
    Author

    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.

  3. scabug commented on Oct 12, 2014

    @scabug
    Author

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

    scala/scala@63207e1

  4. scabug commented on Oct 12, 2014

    @scabug
    Author

    @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.

  5. scabug commented on Oct 12, 2014

    @scabug
    Author

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

  6. scabug commented on Oct 12, 2014

    @scabug
    Author

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

  7. scabug commented on Oct 12, 2014

    @scabug
    Author

    @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.

  8. scabug commented on Oct 12, 2014

    @scabug
    Author
  9. scabug commented on Oct 12, 2014

    @scabug
    Author

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

  10. scabug commented on Oct 12, 2014

    @scabug
    Author

    @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!

  11. scabug commented on Oct 12, 2014

    @scabug
    Author

    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?

  12. scabug commented on Oct 13, 2014

    @scabug
    Author

    @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.

  13. scabug commented on Oct 13, 2014

    @scabug
    Author

    @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).

  14. scabug commented on Oct 13, 2014

    @scabug
    Author

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

  15. scabug commented on Oct 20, 2014

    @scabug
    Author

    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:

    scala-garden/dbuild#146.

  16. scabug commented on Oct 20, 2014

    @scabug
    Author

    @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

  17. added this to the 2.11.4 milestone on Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions