Bazel: Large java_library crashes javac - compiler message file broken on OS X

Created on 6 Jul 2019  路  6Comments  路  Source: bazelbuild/bazel

Description of the problem:

Large javac module crashes with the following on a java_library target with a "high number" (260) of dependencies which are a mix of jars (230) and in repo modules (30).

ERROR: /Users/nfisher/-snip-/BUILD.bazel:1:1: Building ui-backend/libui_backend-class.jar (823 source files) failed (Exit 1)
compiler message file broken: key=compiler.misc.msg.bug arguments=11.0.1, {1}, {2}, {3}, {4}, {5}, {6}, {7}
java.lang.AssertionError
    at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
    at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$2$1.setOverloadKind(DeferredAttr.java:172)
    at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitReference(ArgumentAttr.java:283)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMemberReference.accept(JCTree.java:2190)
    at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:197)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:751)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1997)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:702)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1773)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1452)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:498)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:481)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculativeLambda(DeferredAttr.java:456)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.canLambdaBodyCompleteNormally(DeferredAttr.java:900)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.visitLambda(DeferredAttr.java:878)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1807)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.complete(DeferredAttr.java:832)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:335)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode.process(DeferredAttr.java:779)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrContext.complete(DeferredAttr.java:626)
    at jdk.compiler/com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:214)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:605)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1563)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1733)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1802)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1776)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve$10.doLookup(Resolve.java:2654)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3293)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3543)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2651)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2645)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3721)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3601)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2110)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2006)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitReturn(Attr.java:1866)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1546)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitIf(Attr.java:1762)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1421)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2598)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1807)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$4.complete(DeferredAttr.java:374)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:335)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:321)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1060)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:887)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:775)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:896)
    at jdk.compiler/com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:181)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:605)
    at jdk.compiler/com.sun.tools.javac.comp.Resolve.checkMethod(Resolve.java:644)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:4120)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3913)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3814)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.checkId(Attr.java:3803)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3696)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2110)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2006)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3573)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2110)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2006)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:498)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:481)
    at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.lambda$processArg$0(ArgumentAttr.java:220)
    at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:242)
    at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.processArg(ArgumentAttr.java:219)
    at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitApply(ArgumentAttr.java:307)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
    at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:197)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:751)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1997)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitReturn(Attr.java:1866)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1546)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1098)
    at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4683)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4574)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4503)
    at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4448)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1341)
    at com.google.devtools.build.buildjar.javac.BlazeJavaCompiler.attribute(BlazeJavaCompiler.java:86)
    at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
    at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
    at com.google.devtools.build.buildjar.javac.BlazeJavacMain.compile(BlazeJavacMain.java:113)
    at com.google.devtools.build.buildjar.ReducedClasspathJavaLibraryBuilder.compileSources(ReducedClasspathJavaLibraryBuilder.java:57)
    at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.compileJavaLibrary(SimpleJavaLibraryBuilder.java:116)
    at com.google.devtools.build.buildjar.SimpleJavaLibraryBuilder.run(SimpleJavaLibraryBuilder.java:123)
    at com.google.devtools.build.buildjar.BazelJavaBuilder.processRequest(BazelJavaBuilder.java:106)
    at com.google.devtools.build.buildjar.BazelJavaBuilder.runPersistentWorker(BazelJavaBuilder.java:68)
    at com.google.devtools.build.buildjar.BazelJavaBuilder.main(BazelJavaBuilder.java:46)

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Unfortunately it only seems to happen at one of our top-level services/java_library targets. All other targets build without error in the same monorepo. This service in particular has a high number of dependencies from other sub-modules in the repo.

I've tried a number of things including dialing down the number of jobs, removing the javac worker strategy, and disabling the error-prone checks with -XepDisableAllChecks in the projects bazelrc.

What operating system are you running Bazel on?

OS X 10.14.5

What's the output of bazel info release?

release 0.27.1

Incidentally this also happened with 0.27 which I just upgraded from.

Have you found anything relevant by searching the web?

Replace these lines with your answer.

Places to look:

Any other information, logs, or outputs that you want to share?

Replace these lines with your answer.

If the files are large, upload as attachment or provide link.

P2 team-Rules-Java bug

All 6 comments

java.lang.AssertionError
    at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
    at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
    at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$2$1.setOverloadKind(DeferredAttr.java:172)

That looks like JDK-8210483.

Ok thanks for that. I鈥檓 hoping to have a minimal test case soon. I鈥檓 currently shifting from sub-module level BUILD files to more granular packages. Unfortunately not straightforward as I need to resolve some circular refs in the DAG.

Would you be looking to upgrade the Java tool chain in a new release?

cc @iirina

The bug is fixed in the JDK 12 javac, which I think will be available in an upcoming Bazel release. It would also be possible to backport to 11.

@nfisher I'll try to add a snippet for how to use a java toolchain with javac 12 next week, so you won't have to wait for a bazel release.

@cushon thanks for the pointers!

Thanks @iirina I've been looking through the tools/jdk Bazel files but not sure if that's the right place to look for examples. Ideally I want to support multi-platform (e.g. linux and OSX).

Is this the most relevant file to look at?
https://github.com/bazelbuild/bazel/blob/master/tools/jdk/BUILD.java_tools

Was this page helpful?
0 / 5 - 0 ratings