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

Null pointer exception when using @local_config_platform//:host #13474

Closed
uhthomas opened this issue May 14, 2021 · 3 comments
Closed

Null pointer exception when using @local_config_platform//:host #13474

uhthomas opened this issue May 14, 2021 · 3 comments
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Configurability platforms, toolchains, cquery, select(), config transitions type: bug

Comments

@uhthomas
Copy link
Contributor

uhthomas commented May 14, 2021

Description of the problem / feature request:

Bazel crashes when using a rule with:

target_compatible_with =  ["@local_config_platform//:host"],

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

Create a target and amend it to include the above snippet. Try building it.

What operating system are you running Bazel on?

linux/amd64

What's the output of bazel info release?

release 4.0.0- (@non-git)

Have you found anything relevant by searching the web?

Not really. I couldn't find this stack trace anywhere.

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

FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ConfiguredTargetKey{label=//test/integration:integration_test, config=BuildConfigurationValue.Key[00fda4c88c6c21307a074c88f10f7f34629019485e5426f1494f953a133c75a0]}' (requested by nodes )
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:563)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:398)
        at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.NullPointerException
        at com.google.devtools.build.lib.analysis.platform.ConstraintCollection.hasConstraintValue(ConstraintCollection.java:216)
        at com.google.devtools.build.lib.analysis.RuleContext.targetPlatformHasConstraint(RuleContext.java:1226)
        at com.google.devtools.build.lib.analysis.constraints.RuleContextConstraintSemantics.lambda$incompatibleConfiguredTarget$1(RuleContextConstraintSemantics.java:904)
        at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176)
        at com.google.common.collect.CollectSpliterators$1.lambda$forEachRemaining$1(CollectSpliterators.java:120)
        at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:720)
        at com.google.common.collect.CollectSpliterators$1.forEachRemaining(CollectSpliterators.java:120)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
        at com.google.devtools.build.lib.analysis.constraints.RuleContextConstraintSemantics.incompatibleConfiguredTarget(RuleContextConstraintSemantics.java:905)
        at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createRule(ConfiguredTargetFactory.java:327)
        at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createConfiguredTarget(ConfiguredTargetFactory.java:194)
        at com.google.devtools.build.lib.skyframe.SkyframeBuildView.createConfiguredTarget(SkyframeBuildView.java:938)
        at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.createConfiguredTarget(ConfiguredTargetFunction.java:1013)
        at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.compute(ConfiguredTargetFunction.java:371)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:477)
        ... 7 more
@uhthomas
Copy link
Contributor Author

I see the same behaviour with @bazel_tools//platforms:host_platform.

My .bazelrc is identical to this.

@aiuto aiuto added team-Configurability platforms, toolchains, cquery, select(), config transitions untriaged labels May 14, 2021
@katre katre self-assigned this May 26, 2021
@katre
Copy link
Member

katre commented May 26, 2021

The underlying issue here is that target_compatible_with is expecting targets from the rule constraint_value, and @local_config_platform//:host is a platform.

It still shouldn't crash, so I will investigate that so that users can get a useful error message.

What are you actually trying to do? If you just want to know what constraints are used in the auto-detected host platform, you can do the following:

load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS")

...
target_compatible_with = HOST_CONSTRAINTS,
...

@katre katre added P2 We'll consider working on this in future. (Assignee optional) type: bug and removed untriaged labels May 26, 2021
@katre
Copy link
Member

katre commented May 26, 2021

The crash was fixed in 24d0864 (making this a duplicate of #12879).

Conveniently for you, that commit was cherrypicked to the just-released Bazel 4.1.0, so upgrade to that, fix your target_compatible_with, and you should be good to go.

@katre katre closed this as completed May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Configurability platforms, toolchains, cquery, select(), config transitions type: bug
Projects
None yet
Development

No branches or pull requests

3 participants