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

crash defining a late-bound attribute #8568

Closed
benjaminp opened this issue Jun 6, 2019 · 6 comments
Closed

crash defining a late-bound attribute #8568

benjaminp opened this issue Jun 6, 2019 · 6 comments
Labels
incompatible-change Incompatible/breaking change P1 I'll work on this now. (Assignee required)

Comments

@benjaminp
Copy link
Collaborator

$ bazel version
Build label: f4523e7dac4e96c924257acc63cbe237c3fc5e24 
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Jun 6 00:00:49 2019 (1559779249)
Build timestamp: 1559779249
Build timestamp as int: 1559779249
$ touch WORKSPACE
$ cat > x.bzl
def _impl(): pass

blah = rule(
    implementation = _impl,
    attrs = {
        ":myattr": attr.label(),
    }
)
$ cat > BUILD 
load(":x.bzl", "blah")
$ bazel build *
Internal error thrown during build. Printing stack trace: java.lang.RuntimeException: Unrecoverable error while evaluating node '//:x.bzl' (requested by nodes 'PACKAGE:')
	at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:528)
	at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:399)
	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.IllegalArgumentException: late bound attributes require a default value that is late bound (and vice versa): :myattr
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:216)
	at com.google.devtools.build.lib.packages.Attribute.<init>(Attribute.java:1938)
	at com.google.devtools.build.lib.packages.Attribute$ImmutableAttributeFactory.build(Attribute.java:415)
	at com.google.devtools.build.lib.analysis.skylark.SkylarkAttr$Descriptor.build(SkylarkAttr.java:886)
	at com.google.devtools.build.lib.analysis.skylark.SkylarkRuleClassFunctions$SkylarkRuleFunction.export(SkylarkRuleClassFunctions.java:683)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.possiblyExport(SkylarkImportLookupFunction.java:566)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.execAndExport(SkylarkImportLookupFunction.java:548)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.createExtension(SkylarkImportLookupFunction.java:528)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.computeInternal(SkylarkImportLookupFunction.java:384)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.compute(SkylarkImportLookupFunction.java:102)
	at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:451)
	... 4 more

INFO: Elapsed time: 0.548s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
    currently loading: 
Internal error thrown during build. Printing stack trace: java.lang.RuntimeException: Unrecoverable error while evaluating node '//:x.bzl' (requested by nodes 'PACKAGE:')
	at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:528)
	at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:399)
	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.IllegalArgumentException: late bound attributes require a default value that is late bound (and vice versa): :myattr
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:216)
	at com.google.devtools.build.lib.packages.Attribute.<init>(Attribute.java:1938)
	at com.google.devtools.build.lib.packages.Attribute$ImmutableAttributeFactory.build(Attribute.java:415)
	at com.google.devtools.build.lib.analysis.skylark.SkylarkAttr$Descriptor.build(SkylarkAttr.java:886)
	at com.google.devtools.build.lib.analysis.skylark.SkylarkRuleClassFunctions$SkylarkRuleFunction.export(SkylarkRuleClassFunctions.java:683)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.possiblyExport(SkylarkImportLookupFunction.java:566)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.execAndExport(SkylarkImportLookupFunction.java:548)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.createExtension(SkylarkImportLookupFunction.java:528)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.computeInternal(SkylarkImportLookupFunction.java:384)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.compute(SkylarkImportLookupFunction.java:102)
	at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:451)
	... 4 more
java.lang.RuntimeException: Unrecoverable error while evaluating node '//:x.bzl' (requested by nodes 'PACKAGE:')
	at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:528)
	at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:399)
	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.IllegalArgumentException: late bound attributes require a default value that is late bound (and vice versa): :myattr
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:216)
	at com.google.devtools.build.lib.packages.Attribute.<init>(Attribute.java:1938)
	at com.google.devtools.build.lib.packages.Attribute$ImmutableAttributeFactory.build(Attribute.java:415)
	at com.google.devtools.build.lib.analysis.skylark.SkylarkAttr$Descriptor.build(SkylarkAttr.java:886)
	at com.google.devtools.build.lib.analysis.skylark.SkylarkRuleClassFunctions$SkylarkRuleFunction.export(SkylarkRuleClassFunctions.java:683)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.possiblyExport(SkylarkImportLookupFunction.java:566)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.execAndExport(SkylarkImportLookupFunction.java:548)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.createExtension(SkylarkImportLookupFunction.java:528)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.computeInternal(SkylarkImportLookupFunction.java:384)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.compute(SkylarkImportLookupFunction.java:102)
	at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:451)
	... 4 more
java.lang.RuntimeException: Unrecoverable error while evaluating node '//:x.bzl' (requested by nodes 'PACKAGE:')
	at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:528)
	at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:399)
	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.IllegalArgumentException: late bound attributes require a default value that is late bound (and vice versa): :myattr
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:216)
	at com.google.devtools.build.lib.packages.Attribute.<init>(Attribute.java:1938)
	at com.google.devtools.build.lib.packages.Attribute$ImmutableAttributeFactory.build(Attribute.java:415)
	at com.google.devtools.build.lib.analysis.skylark.SkylarkAttr$Descriptor.build(SkylarkAttr.java:886)
	at com.google.devtools.build.lib.analysis.skylark.SkylarkRuleClassFunctions$SkylarkRuleFunction.export(SkylarkRuleClassFunctions.java:683)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.possiblyExport(SkylarkImportLookupFunction.java:566)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.execAndExport(SkylarkImportLookupFunction.java:548)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.createExtension(SkylarkImportLookupFunction.java:528)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.computeInternal(SkylarkImportLookupFunction.java:384)
	at com.google.devtools.build.lib.skyframe.SkylarkImportLookupFunction.compute(SkylarkImportLookupFunction.java:102)
FAILED: Build did NOT complete successfully (0 packages loaded)

@laurentlb
Copy link
Contributor

We should provide a proper error message, but attribute names may not start or contain special characters like :.

@benjaminp
Copy link
Collaborator Author

Okay, but writing '$'-prefixed attributes has at least historically been essential for working on around bugs like #6293.

@laurentlb
Copy link
Contributor

The only convention that's supported is "_myattr": attr.label().
In 6293, I see the commit is using "_lcov_merger" (jayconrod/rules_go@593d269), so that's fine for me.

@benjaminp
Copy link
Collaborator Author

I used the name $lcov_merger successfully in my project. My point here is that enforcing such a restriction is an incompatible change.

@laurentlb
Copy link
Contributor

laurentlb commented Jun 11, 2019

Yes, I agree. We should add an incompatible flag for that.

@laurentlb laurentlb added incompatible-change Incompatible/breaking change P1 I'll work on this now. (Assignee required) and removed untriaged labels Jun 11, 2019
@laurentlb
Copy link
Contributor

This breaking change is tracked here: #6437

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompatible-change Incompatible/breaking change P1 I'll work on this now. (Assignee required)
Projects
None yet
Development

No branches or pull requests

3 participants