bazel-contrib/rules_go

building packages with visibility is broken with rules_go 0.6.0 and bazel 0.5.4

nlacasse opened this issue · 2 comments

With rules_go version 0.6.0 and Bazel version 0.5.4, building a simple package with a visibility attribute fails.

Here is a repro case:
https://github.com/nlacasse/rules_go/tree/visibility_test/tests/visibility

bazel build //tests/visibility:foo                                                                                                                                                                                                        
...........
Unhandled exception thrown during build; message: Unrecoverable error while evaluating node 'CONFIGURED_TARGET://tests/visibility:foo 0f763d6a9b9fd42cc649394441b374f2 (1803222502 2081008356)' (requested by nodes )
INFO: Elapsed time: 3.308s
FAILED: Build did NOT complete successfully (15 packages loaded)
java.lang.RuntimeException: Unrecoverable error while evaluating node 'CONFIGURED_TARGET://tests/visibility:foo 0f763d6a9b9fd42cc649394441b374f2 (1803222502 2081008356)' (requested by nodes )
        at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:475)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:352)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
        at com.google.devtools.build.lib.analysis.ToolchainContext.lambda$findToolchains$0(ToolchainContext.java:131)
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
        at com.google.common.collect.CollectSpliterators$1.lambda$tryAdvance$0(CollectSpliterators.java:110)
        at java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1812)
        at com.google.common.collect.CollectSpliterators$1.tryAdvance(CollectSpliterators.java:109)
        at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
        at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
        at com.google.devtools.build.lib.analysis.ToolchainContext.findToolchains(ToolchainContext.java:132)
        at com.google.devtools.build.lib.analysis.ToolchainContext.resolveToolchains(ToolchainContext.java:89)
        at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createRule(ConfiguredTargetFactory.java:298)
        at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createConfiguredTarget(ConfiguredTargetFactory.java:228)
        at com.google.devtools.build.lib.skyframe.SkyframeBuildView.createConfiguredTarget(SkyframeBuildView.java:494)
        at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.createConfiguredTarget(ConfiguredTargetFunction.java:1164)
        at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.compute(ConfiguredTargetFunction.java:269)
        at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:400)
        ... 4 more
java.lang.RuntimeException: Unrecoverable error while evaluating node 'CONFIGURED_TARGET://tests/visibility:foo 0f763d6a9b9fd42cc649394441b374f2 (1803222502 2081008356)' (requested by nodes )
        at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:475)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:352)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
        at com.google.devtools.build.lib.analysis.ToolchainContext.lambda$findToolchains$0(ToolchainContext.java:131)
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
        at com.google.common.collect.CollectSpliterators$1.lambda$tryAdvance$0(CollectSpliterators.java:110)
        at java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1812)
        at com.google.common.collect.CollectSpliterators$1.tryAdvance(CollectSpliterators.java:109)
        at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
        at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
        at com.google.devtools.build.lib.analysis.ToolchainContext.findToolchains(ToolchainContext.java:132)
        at com.google.devtools.build.lib.analysis.ToolchainContext.resolveToolchains(ToolchainContext.java:89)
        at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createRule(ConfiguredTargetFactory.java:298)
        at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createConfiguredTarget(ConfiguredTargetFactory.java:228)
        at com.google.devtools.build.lib.skyframe.SkyframeBuildView.createConfiguredTarget(SkyframeBuildView.java:494)
        at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.createConfiguredTarget(ConfiguredTargetFunction.java:1164)
        at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.compute(ConfiguredTargetFunction.java:269)
        at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:400)
        ... 4 more

This exact example works correctly with Bazel 0.6.1

This looks like a bug in Bazel itself. Nothing in rules_go should cause Bazel to crash. Could you raise this issue in bazelbuild/bazel?

We'll see if we can understand what causes this. Maybe there's a workaround on our side.

Sure. Filed bazelbuild/bazel#3883

I should have clarified that this package works with rules_go 0.5.4 and Bazel 0.5.4, and also with rules_go 0.6.0 and Bazel 0.6.1.

So there is something about the combination of rules_go 0.6.0 and Bazel 0.5.4 which causes this error.

Unfortunately, I rely on an external service for CI testing, and they have not upgraded their Bazel version yet. Until they do, I'm unable to upgrade to the new rules_go.