bazelbuild / bazel

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

Adding `timeout` to repository rules as str instead of int causes a crash #14624

Open UebelAndre opened 2 years ago

UebelAndre commented 2 years ago

Description of the problem / feature request:

I'm attempting to add a timeout attribute to a repository rule in https://github.com/bazelbuild/rules_rust/pull/1101 and am running into the following crash

FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.IllegalStateException: java.lang.RuntimeException: Unrecoverable error while evaluating node '[/Users/buildkite/builds/bk-imacpro-7/bazel/rules-rust-rustlang/examples/crate_universe]/[WORKSPACE.bazel], 2' (requested by nodes 'com.google.devtools.build.lib.skyframe.ExternalPackageFunction$$Lambda$230/0x0000000800297040@3425876c')
    at com.google.devtools.build.lib.skyframe.SkyframeExecutor.evaluateSkyKeys(SkyframeExecutor.java:2257)
    at com.google.devtools.build.lib.skyframe.SkyframeExecutor.getConfigurations(SkyframeExecutor.java:2032)
    at com.google.devtools.build.lib.skyframe.SkyframeExecutor.getConfiguration(SkyframeExecutor.java:1979)
    at com.google.devtools.build.lib.runtime.commands.InfoCommand.lambda$exec$0(InfoCommand.java:164)
    at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:167)
    at com.google.devtools.build.lib.runtime.commands.InfoCommand.exec(InfoCommand.java:235)
    at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:585)
    at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:231)
    at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:550)
    at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$1(GrpcServerImpl.java:614)
    at io.grpc.Context$1.run(Context.java:579)
    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)
Caused by: java.lang.RuntimeException: Unrecoverable error while evaluating node '[/Users/buildkite/builds/bk-imacpro-7/bazel/rules-rust-rustlang/examples/crate_universe]/[WORKSPACE.bazel], 2' (requested by nodes 'com.google.devtools.build.lib.skyframe.ExternalPackageFunction$$Lambda$230/0x0000000800297040@3425876c')
    at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:674)
    at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:382)
    ... 3 more
Caused by: net.starlark.java.eval.Starlark$UncheckedEvalException: IllegalStateException thrown during Starlark evaluation (WORKSPACE)
    at <starlark>.repository_rule(<builtin>:0)
    at <starlark>.crate_universe_bootstrap(/private/var/tmp/_bazel_buildkite/f45027b31f3efe2fe255bdfa1be66dd8/external/rules_rust/crate_universe/bootstrap.bzl:10)
    at <starlark>.<toplevel>(/Users/buildkite/builds/bk-imacpro-7/bazel/rules-rust-rustlang/examples/crate_universe/WORKSPACE.bazel:19)
Caused by: java.lang.IllegalStateException: Attribute 'timeout' is potentially configurable - not allowed here
    at com.google.common.base.Preconditions.checkState(Preconditions.java:591)
    at com.google.devtools.build.lib.packages.NonconfigurableAttributeMapper.get(NonconfigurableAttributeMapper.java:45)
    at com.google.devtools.build.lib.packages.RuleClass.checkForValidSizeAndTimeoutValues(RuleClass.java:2478)
    at com.google.devtools.build.lib.packages.RuleClass.createRule(RuleClass.java:2097)
    at com.google.devtools.build.lib.packages.RuleFactory.createRule(RuleFactory.java:120)
    at com.google.devtools.build.lib.packages.WorkspaceFactoryHelper.createAndAddRepositoryRule(WorkspaceFactoryHelper.java:52)
    at com.google.devtools.build.lib.bazel.repository.starlark.StarlarkRepositoryModule$RepositoryRuleFunction.createRuleLegacy(StarlarkRepositoryModule.java:249)
    at com.google.devtools.build.lib.bazel.repository.starlark.StarlarkRepositoryModule$RepositoryRuleFunction.call(StarlarkRepositoryModule.java:191)
    at net.starlark.java.eval.StarlarkCallable.fastcall(StarlarkCallable.java:86)
    at net.starlark.java.eval.Starlark.fastcall(Starlark.java:619)
    at net.starlark.java.eval.Eval.evalCall(Eval.java:672)
    at net.starlark.java.eval.Eval.eval(Eval.java:489)
    at net.starlark.java.eval.Eval.exec(Eval.java:271)
    at net.starlark.java.eval.Eval.execStatements(Eval.java:82)
    at net.starlark.java.eval.Eval.execFunctionBody(Eval.java:66)
    at net.starlark.java.eval.StarlarkFunction.fastcall(StarlarkFunction.java:191)
    at net.starlark.java.eval.Starlark.fastcall(Starlark.java:619)
    at net.starlark.java.eval.Eval.evalCall(Eval.java:672)
    at net.starlark.java.eval.Eval.eval(Eval.java:489)
    at net.starlark.java.eval.Eval.execReturn(Eval.java:249)
    at net.starlark.java.eval.Eval.exec(Eval.java:288)
    at net.starlark.java.eval.Eval.execStatements(Eval.java:82)
    at net.starlark.java.eval.Eval.execFunctionBody(Eval.java:66)
    at net.starlark.java.eval.StarlarkFunction.fastcall(StarlarkFunction.java:191)
    at net.starlark.java.eval.Starlark.fastcall(Starlark.java:619)
    at net.starlark.java.eval.Starlark.execFileProgram(Starlark.java:905)
    at com.google.devtools.build.lib.packages.WorkspaceFactory.execute(WorkspaceFactory.java:157)
    at com.google.devtools.build.lib.skyframe.WorkspaceFileFunction.compute(WorkspaceFileFunction.java:325)
    at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:590)
    at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:382)
    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)
Traceback (most recent call last):
  File "/Users/buildkite/builds/bk-imacpro-7/bazel/rules-rust-rustlang/bazelci.py", line 3483, in <module>
    sys.exit(main())
  File "/Users/buildkite/builds/bk-imacpro-7/bazel/rules-rust-rustlang/bazelci.py", line 3449, in main
    execute_commands(
  File "/Users/buildkite/builds/bk-imacpro-7/bazel/rules-rust-rustlang/bazelci.py", line 1215, in execute_commands
    bazel_version = print_bazel_version_info(bazel_binary, platform)
  File "/Users/buildkite/builds/bk-imacpro-7/bazel/rules-rust-rustlang/bazelci.py", line 1444, in print_bazel_version_info
    execute_command(
  File "/Users/buildkite/builds/bk-imacpro-7/bazel/rules-rust-rustlang/bazelci.py", line 2127, in execute_command
    return subprocess.run(
  File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['bazel', '--nomaster_bazelrc', '--bazelrc=/dev/null', 'info']' returned non-zero exit status 37.
🚨 Error: The command exited with status 1
user command error: exit status 1

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

Adding the following to any repository rule reproduces the issue

"timeout": attr.string(
    default = "600",
)

What operating system are you running Bazel on?

Linux, MacOS, Windows

What's the output of bazel info release?

INFO: Invocation ID: 0b44b180-e0b4-4c37-9e5a-92a1a62a1c0a
release 4.2.1
UebelAndre commented 2 years ago

Ah, this turned out to just be a series of unexpected events.

timeout is actually an int but before I ran into that failure, I hit the crash above which made the issue more confusing than it should be.

github-actions[bot] commented 9 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.

UebelAndre commented 9 months ago

To my knowledge this still causes a crash.