bazelbuild / bazel

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

Crash from `ctx.actions.declare_file("")` #14625

Closed GMNGeoffrey closed 2 months ago

GMNGeoffrey commented 2 years ago

Description of the problem / feature request:

Replace this line with your answer.

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

  1. Clone and check out https://github.com/GMNGeoffrey/iree/commit/899447b3584fd40d2eed353e960e2c8e335c0dc9
  2. Run python[3] configure_bazel.py
  3. Run bazel test //iree/compiler/Dialect/HAL/IR/test:all

What operating system are you running Bazel on?

Linux Debian

What's the output of bazel info release?

release 4.2.2

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

You should really stop assuming that this indicates someones git remote. Link to specific commit is above.

Have you found anything relevant by searching the web?

No

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

I'm assuming there's something about how my rule is configured that is making Bazel upset. I think it's that the native_binary out is derived from name, but regardless it seems like an internal error -> bug

Stack trace:

FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ConfiguredTargetKey{label=//iree/compiler/Dialect/HAL/IR/test:command_buffer_folding.mlir.test, config=BuildConfigurationValue.Key[9f4263a802fade066cb992d27e0966a8c92054212aa787473842eb125b6007bb]}' (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.IllegalStateException: Output artifact 'iree/compiler/Dialect/HAL/IR/test.runfiles_manifest' not under package directory 'iree/compiler/Dialect/HAL/IR/test' for target '//iree/compiler/Dialect/HAL/IR/test:command_buffer_folding.mlir.test'
        at com.google.common.base.Preconditions.checkState(Preconditions.java:843)
        at com.google.devtools.build.lib.analysis.RuleContext.getDerivedArtifact(RuleContext.java:831)
        at com.google.devtools.build.lib.analysis.RuleContext.getDerivedArtifact(RuleContext.java:821)
        at com.google.devtools.build.lib.analysis.RunfilesSupport.createRunfilesInputManifestArtifact(RunfilesSupport.java:242)
        at com.google.devtools.build.lib.analysis.RunfilesSupport.create(RunfilesSupport.java:131)
        at com.google.devtools.build.lib.analysis.RunfilesSupport.withExecutable(RunfilesSupport.java:420)
        at com.google.devtools.build.lib.analysis.starlark.StarlarkRuleConfiguredTargetUtil.addSimpleProviders(StarlarkRuleConfiguredTargetUtil.java:629)
        at com.google.devtools.build.lib.analysis.starlark.StarlarkRuleConfiguredTargetUtil.parseDefaultProviderFields(StarlarkRuleConfiguredTargetUtil.java:568)
        at com.google.devtools.build.lib.analysis.starlark.StarlarkRuleConfiguredTargetUtil.addProviders(StarlarkRuleConfiguredTargetUtil.java:352)
        at com.google.devtools.build.lib.analysis.starlark.StarlarkRuleConfiguredTargetUtil.createTarget(StarlarkRuleConfiguredTargetUtil.java:217)
        at com.google.devtools.build.lib.analysis.starlark.StarlarkRuleConfiguredTargetUtil.buildRule(StarlarkRuleConfiguredTargetUtil.java:149)
        at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createRule(ConfiguredTargetFactory.java:369)
        at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createConfiguredTarget(ConfiguredTargetFactory.java:195)
        at com.google.devtools.build.lib.skyframe.SkyframeBuildView.createConfiguredTarget(SkyframeBuildView.java:940)
        at com.google.devtools.build.lib.skyframe.ConfiguredTargetFunction.createConfiguredTarget(ConfiguredTargetFunction.java:1031)
        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
GMNGeoffrey commented 2 years ago

Too help you narrow your search, this is the line that I think is causing the crash: https://github.com/GMNGeoffrey/iree/blob/899447b3584fd40d2eed353e960e2c8e335c0dc9/build_tools/bazel/native_binary.bzl#L24-L27

GMNGeoffrey commented 2 years ago

Yes, the issue is that fetching from an unset string attribute gives the empty string, not None, so the crash is caused by ctx.actions.declare_file("")

github-actions[bot] commented 5 months ago

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

github-actions[bot] commented 2 months ago

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please post @bazelbuild/triage in a comment here and we'll take a look. Thanks!