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

Bazel hard crashes when 'inputs' argument to 'ctx.action' is a RuleConfiguredTarget #3714

Closed
endobson opened this issue Sep 9, 2017 · 2 comments
Assignees
Labels
P1 I'll work on this now. (Assignee required)

Comments

@endobson
Copy link
Contributor

endobson commented Sep 9, 2017

It looks like the code is assuming that any value that flows in has been checked by the @Param type, but that seems to not be the case.

@Param for the argument:

@Param(
name = "inputs",
allowedTypes = {
@ParamType(type = SkylarkList.class),
@ParamType(type = SkylarkNestedSet.class),
},
generic1 = Artifact.class,
defaultValue = "[]",
named = true,
positional = false,
doc = "list of the input files of the action."
),

Where the cast happens:

Iterable<Artifact> inputArtifacts;
if (inputs instanceof SkylarkList) {
inputArtifacts = ((SkylarkList) inputs).getContents(Artifact.class, "inputs");
builder.addInputs(inputArtifacts);
} else {
inputArtifacts = ((SkylarkNestedSet) inputs).toCollection(Artifact.class);
builder.addInputs(((SkylarkNestedSet) inputs).getSet(Artifact.class));
}

Error message:

INFO: Reading 'startup' options from /Users/endobson/.bazelrc: --watchfs
................
____Loading package: tests/test-data
____Loading package: @bazel_tools//tools/cpp
____Loading package: @local_jdk//
____Loading package: @local_config_cc//
____Loading package: @local_config_xcode//
____Loading complete.  Analyzing...
____Loading package: @com_google_protobuf//
____Loading package: @bazel_tools//tools/genrule
____Loading package: 
____Loading package: @racket_minimal_x86_64_6_10_osx//file
Unhandled exception thrown during build; message: Unrecoverable error while evaluating node 'ASPECT:[]#//:racket_proto_library.bzl%racket_proto_library_aspect 03404db0c64cd2322ae1929c923ef28b 03404db0c64cd2322ae1929c923ef28b {}' (requested by nodes 'CONFIGURED_TARGET://tests/test-data:foo_proto_rkt 03404db0c64cd2322ae1929c923ef28b (1600830686 183214234)')
____Elapsed time: 2.595s
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ASPECT:[]#//:racket_proto_library.bzl%racket_proto_library_aspect 03404db0c64cd2322ae1929c923ef28b 03404db0c64cd2322ae1929c923ef28b {}' (requested by nodes 'CONFIGURED_TARGET://tests/test-data:foo_proto_rkt 03404db0c64cd2322ae1929c923ef28b (1600830686 183214234)')
	at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:475)
	at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:352)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: com.google.devtools.build.lib.analysis.RuleConfiguredTarget cannot be cast to com.google.devtools.build.lib.syntax.SkylarkNestedSet
	at com.google.devtools.build.lib.rules.SkylarkActionFactory.registerSpawnAction(SkylarkActionFactory.java:578)
	at com.google.devtools.build.lib.rules.SkylarkActionFactory.run(SkylarkActionFactory.java:384)
	at com.google.devtools.build.lib.rules.SkylarkRuleImplementationFunctions$1.invoke(SkylarkRuleImplementationFunctions.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.google.devtools.build.lib.syntax.BuiltinFunction.call(BuiltinFunction.java:166)
	at com.google.devtools.build.lib.syntax.BaseFunction.call(BaseFunction.java:428)
	at com.google.devtools.build.lib.syntax.FuncallExpression.invokeObjectMethod(FuncallExpression.java:644)
	at com.google.devtools.build.lib.syntax.FuncallExpression.invokeObjectMethod(FuncallExpression.java:741)
	at com.google.devtools.build.lib.syntax.FuncallExpression.doEval(FuncallExpression.java:727)
	at com.google.devtools.build.lib.syntax.Expression.eval(Expression.java:45)
	at com.google.devtools.build.lib.syntax.ExpressionStatement.doExec(ExpressionStatement.java:43)
	at com.google.devtools.build.lib.syntax.Statement.exec(Statement.java:31)
	at com.google.devtools.build.lib.syntax.UserDefinedFunction.call(UserDefinedFunction.java:83)
	at com.google.devtools.build.lib.syntax.BaseFunction.call(BaseFunction.java:428)
	at com.google.devtools.build.lib.syntax.FuncallExpression.callFunction(FuncallExpression.java:764)
	at com.google.devtools.build.lib.syntax.FuncallExpression.invokeGlobalFunction(FuncallExpression.java:750)
	at com.google.devtools.build.lib.syntax.FuncallExpression.doEval(FuncallExpression.java:727)
	at com.google.devtools.build.lib.syntax.Expression.eval(Expression.java:45)
	at com.google.devtools.build.lib.syntax.ExpressionStatement.doExec(ExpressionStatement.java:43)
	at com.google.devtools.build.lib.syntax.Statement.exec(Statement.java:31)
	at com.google.devtools.build.lib.syntax.ForStatement.doExec(ForStatement.java:82)
	at com.google.devtools.build.lib.syntax.Statement.exec(Statement.java:31)
	at com.google.devtools.build.lib.syntax.UserDefinedFunction.call(UserDefinedFunction.java:83)
	at com.google.devtools.build.lib.syntax.BaseFunction.call(BaseFunction.java:428)
	at com.google.devtools.build.lib.skyframe.SkylarkAspectFactory.create(SkylarkAspectFactory.java:79)
	at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createAspect(ConfiguredTargetFactory.java:433)
	at com.google.devtools.build.lib.skyframe.AspectFunction.createAspect(AspectFunction.java:471)
	at com.google.devtools.build.lib.skyframe.AspectFunction.compute(AspectFunction.java:320)
	at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:400)
	... 4 more
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ASPECT:[]#//:racket_proto_library.bzl%racket_proto_library_aspect 03404db0c64cd2322ae1929c923ef28b 03404db0c64cd2322ae1929c923ef28b {}' (requested by nodes 'CONFIGURED_TARGET://tests/test-data:foo_proto_rkt 03404db0c64cd2322ae1929c923ef28b (1600830686 183214234)')
	at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:475)
	at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:352)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: com.google.devtools.build.lib.analysis.RuleConfiguredTarget cannot be cast to com.google.devtools.build.lib.syntax.SkylarkNestedSet
	at com.google.devtools.build.lib.rules.SkylarkActionFactory.registerSpawnAction(SkylarkActionFactory.java:578)
	at com.google.devtools.build.lib.rules.SkylarkActionFactory.run(SkylarkActionFactory.java:384)
	at com.google.devtools.build.lib.rules.SkylarkRuleImplementationFunctions$1.invoke(SkylarkRuleImplementationFunctions.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.google.devtools.build.lib.syntax.BuiltinFunction.call(BuiltinFunction.java:166)
	at com.google.devtools.build.lib.syntax.BaseFunction.call(BaseFunction.java:428)
	at com.google.devtools.build.lib.syntax.FuncallExpression.invokeObjectMethod(FuncallExpression.java:644)
	at com.google.devtools.build.lib.syntax.FuncallExpression.invokeObjectMethod(FuncallExpression.java:741)
	at com.google.devtools.build.lib.syntax.FuncallExpression.doEval(FuncallExpression.java:727)
	at com.google.devtools.build.lib.syntax.Expression.eval(Expression.java:45)
	at com.google.devtools.build.lib.syntax.ExpressionStatement.doExec(ExpressionStatement.java:43)
	at com.google.devtools.build.lib.syntax.Statement.exec(Statement.java:31)
	at com.google.devtools.build.lib.syntax.UserDefinedFunction.call(UserDefinedFunction.java:83)
	at com.google.devtools.build.lib.syntax.BaseFunction.call(BaseFunction.java:428)
	at com.google.devtools.build.lib.syntax.FuncallExpression.callFunction(FuncallExpression.java:764)
	at com.google.devtools.build.lib.syntax.FuncallExpression.invokeGlobalFunction(FuncallExpression.java:750)
	at com.google.devtools.build.lib.syntax.FuncallExpression.doEval(FuncallExpression.java:727)
	at com.google.devtools.build.lib.syntax.Expression.eval(Expression.java:45)
	at com.google.devtools.build.lib.syntax.ExpressionStatement.doExec(ExpressionStatement.java:43)
	at com.google.devtools.build.lib.syntax.Statement.exec(Statement.java:31)
	at com.google.devtools.build.lib.syntax.ForStatement.doExec(ForStatement.java:82)
	at com.google.devtools.build.lib.syntax.Statement.exec(Statement.java:31)
	at com.google.devtools.build.lib.syntax.UserDefinedFunction.call(UserDefinedFunction.java:83)
	at com.google.devtools.build.lib.syntax.BaseFunction.call(BaseFunction.java:428)
	at com.google.devtools.build.lib.skyframe.SkylarkAspectFactory.create(SkylarkAspectFactory.java:79)
	at com.google.devtools.build.lib.analysis.ConfiguredTargetFactory.createAspect(ConfiguredTargetFactory.java:433)
	at com.google.devtools.build.lib.skyframe.AspectFunction.createAspect(AspectFunction.java:471)
	at com.google.devtools.build.lib.skyframe.AspectFunction.compute(AspectFunction.java:320)
	at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:400)
	... 4 more

Release 0.5.4

@philwo philwo added category: extensibility > skylark P1 I'll work on this now. (Assignee required) labels Sep 11, 2017
@dslomov dslomov assigned dslomov and unassigned laurentlb Sep 19, 2017
@dslomov
Copy link
Contributor

dslomov commented Sep 19, 2017

working on this.

@davido
Copy link
Contributor

davido commented Sep 21, 2017

It seems, that this CL introduced breakage in rules_closure,
and as the consequence, Gerrit Code Review cannot be built
from the HEAD any more, see: #3782.

bazel-io pushed a commit that referenced this issue Sep 22, 2017
*** Reason for rollback ***

Rolled back commit enforces stricter parameter checks. Will fix and roll forward
This creates several failures on the nightly build of Bazel:

ERROR: /home/ci/workspace/Global/rules_closure-node=linux-x86_64/closure/protobuf/test/BUILD:23:1: no such package '@com_google_protobuf_protoc//': Cannot convert parameter 'url' to type string or sequence of strings, in method download_and_extract(List, string, string, string, string) of 'repository_ctx' and referenced by '//closure/protobuf/test:example_proto_gen'.
ERROR: Analysis of target '//closure/protobuf/test:example_lib' failed; build aborted: no such package '@com_google_protobuf_protoc//': Cannot convert parameter 'url' to type string or sequence of strings, in method download_and_extract(List, string, string, string, string) of 'repository_ctx'.

*** Original change description ***

Check parameter types for methods when multiple types are allowed.

Fixes #3714
RELNOTES: None.
PiperOrigin-RevId: 169669802
@damienmg damienmg reopened this Sep 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required)
Projects
None yet
Development

No branches or pull requests

7 participants