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

FATAL: bazel crashed due to an internal error. - Platforms #12879

Closed
thna123459 opened this issue Jan 22, 2021 · 3 comments
Closed

FATAL: bazel crashed due to an internal error. - Platforms #12879

thna123459 opened this issue Jan 22, 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

@thna123459
Copy link

Description of the problem / feature request:

Crash NullPointerException

$ ./run.sh
Starting local Bazel server and connecting to it...
Analyzing: target //:main (24 packages loaded, 576 targets configured)
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ConfiguredTargetKey{label=//:main, config=BuildConfigurationValue.Key[86e57527e1c8bb10edc853e734cb858f8159d8f3e0a4df9ceb16f80aad784b93]}' (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(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
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(Unknown Source)
	at com.google.common.collect.CollectSpliterators$1.lambda$forEachRemaining$1(CollectSpliterators.java:120)
	at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(Unknown Source)
	at com.google.common.collect.CollectSpliterators$1.forEachRemaining(CollectSpliterators.java:120)
	at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
	at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
	at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source)
	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

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

Run bazelisk build :main with Bazel 4.0.0 on MacOS with the following BUILD file:

platform(
    name = "myplatform",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:arm",
    ],
)

java_binary(
    name = "main",
    srcs = ["Foo.java"],
    main_class = "Foo",
    target_compatible_with = [":myplatform"]
)

What operating system are you running Bazel on?

MacOS or Linux

What's the output of bazel info release?

$ bazel info release
Starting local Bazel server and connecting to it...
release 4.0.0

Have you found anything relevant by searching the web?

No.

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

See attachment: testcase.tar.gz

@gregestren gregestren added team-Configurability platforms, toolchains, cquery, select(), config transitions type: bug untriaged labels Jan 26, 2021
@katre
Copy link
Member

katre commented Jan 29, 2021

The crash is concerning and I'll address it immediately. Bazel shouldn't crash, it should fail gracefully and report an error.

The good news is, there's a simple fix: the correct type of target to use in target_compatible_with is a constraint_value, not a platform target. If you re-write your target to be:

java_binary(
    name = "main",
    srcs = ["Foo.java"],
    main_class = "Foo",
    target_compatible_with = [
        "@platforms//os:linux",
        "@platforms//cpu:arm",
    ],
)

This will correctly report that the target can't be built.

@katre katre self-assigned this Jan 29, 2021
@katre katre added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Jan 29, 2021
katre added a commit to katre/bazel that referenced this issue Jan 29, 2021
provider.

Also update PlatformProviderUtils to work directly with Lists.

This prevents a few types of crash that can occur from having null
values in a List.

Fixes bazelbuild#12879.
@gjasny gjasny mentioned this issue Feb 24, 2021
9 tasks
philwo pushed a commit that referenced this issue Mar 15, 2021
provider.

Also update PlatformProviderUtils to work directly with Lists.

This prevents a few types of crash that can occur from having null
values in a List.

Fixes #12879.

Closes #12931.

PiperOrigin-RevId: 354595201
philwo pushed a commit that referenced this issue Mar 15, 2021
provider.

Also update PlatformProviderUtils to work directly with Lists.

This prevents a few types of crash that can occur from having null
values in a List.

Fixes #12879.

Closes #12931.

PiperOrigin-RevId: 354595201
@holaworlds
Copy link

holaworlds commented Aug 3, 2021

I am receiving simirlar error. My bazel version is : bazel 4.1.0 running on MacOS

Screen Shot 2021-08-03 at 10 40 34 PM

@katre
Copy link
Member

katre commented Aug 3, 2021

@holaworlds This is a similar error message but a different underlying cause. Please open a new issue with details on how to reproduce the error.

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

Successfully merging a pull request may close this issue.

4 participants