bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
22.77k stars 3.99k forks source link

Bazel crashes when building with option --host_platform="" #22564

Open AlexanderGolovlev opened 1 month ago

AlexanderGolovlev commented 1 month ago

Description of the bug:

We were using the option --host_platform="" to override the value specified in .bazelrc by default one. This worked fine before 7.0, but now it causes the crash with following message:

FATAL: bazel crashed due to an internal error. Printing stack trace: java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:903) at com.google.common.collect.SingletonImmutableList.<init>(SingletonImmutableList.java:39) at com.google.common.collect.ImmutableList.of(ImmutableList.java:100) at com.google.devtools.build.lib.skyframe.config.PlatformMappingValue.computeMapping(PlatformMappingValue.java:251) at com.github.benmanes.caffeine.cache.LocalLoadingCache.lambda$newMappingFunction$3(LocalLoadingCache.java:197) at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$13(BoundedLocalCache.java:2451) at java.base/java.util.concurrent.ConcurrentHashMap.compute(Unknown Source) at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2449) at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2432) at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:107) at com.github.benmanes.caffeine.cache.LocalLoadingCache.get(LocalLoadingCache.java:57) at com.google.devtools.build.lib.skyframe.config.PlatformMappingValue.map(PlatformMappingValue.java:201) at com.google.devtools.build.lib.skyframe.SkyframeExecutor.createBuildConfigurationKey(SkyframeExecutor.java:1801) at com.google.devtools.build.lib.skyframe.SkyframeExecutor.getConfiguration(SkyframeExecutor.java:1733) at com.google.devtools.build.lib.skyframe.SkyframeExecutor.createConfiguration(SkyframeExecutor.java:1489) at com.google.devtools.build.lib.analysis.BuildView.update(BuildView.java:250) at com.google.devtools.build.lib.buildtool.AnalysisAndExecutionPhaseRunner.runAnalysisAndExecutionPhase(AnalysisAndExecutionPhaseRunner.java:241) at com.google.devtools.build.lib.buildtool.AnalysisAndExecutionPhaseRunner.execute(AnalysisAndExecutionPhaseRunner.java:139) at com.google.devtools.build.lib.buildtool.BuildTool.buildTargetsWithMergedAnalysisExecution(BuildTool.java:305) at com.google.devtools.build.lib.buildtool.BuildTool.buildTargets(BuildTool.java:173) at com.google.devtools.build.lib.buildtool.BuildTool.processRequest(BuildTool.java:510) at com.google.devtools.build.lib.buildtool.BuildTool.processRequest(BuildTool.java:478) at com.google.devtools.build.lib.runtime.commands.BuildCommand.exec(BuildCommand.java:103) at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:664) at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:244) at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:573) at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$1(GrpcServerImpl.java:644) at io.grpc.Context$1.run(Context.java:566) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source)

Which category does this issue belong to?

Configurability

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

Just build any c++ target (for example, //examples/cpp:srcs from Bazel repo) with command line option --host_platform="" or --host_platform=: bazel build //examples/cpp:srcs --host_platform=

Which operating system are you running Bazel on?

Windows

What is the output of bazel info release?

release 7.0.2

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

Yes, this works fine with version 6.5.0.

Have you found anything relevant by searching the web?

No response

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

The workaround is using the option with non-empty value --host_platform=@local_config_platform//:host.

gregestren commented 1 month ago

Thanks for the report. This sounds like a simple enough root cause / fix.