-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
NullPointerException from aquery with aspects and protobuf output #15716
Comments
After further investigation here are some observations. ActionGraphProtoOutputFormatterCallback.processOutput() is calling accessor.getAspectValues(configuredTarget) but not checking whether the values are null, which causes the NPE around line 104. A similar class ActionGraphTextOutputFormatterCallback has a simple null check in its processOutput() that guards against this. There should probably be a null check in all OutputFormatterCallback classes, including ActionGraphSummaryOutputFormatterCallback. They all call ConfiguredTargetValueAccessor.getAspectValues(), which gets aspect values from walkableGraph.getValue() and this method is declared @nullable, so we can expect nulls to show up in the Collection in some cases. More than just the NPE, there appears to be some kind of a caching problem as well. Of the two commands above, the first one exhibits this null pointer problem, but only with this specific target. The revDeps looks something like this in ConfiguredTargetValueAccessor:
Since the foo_aspect's value is null, I checked walkableGraph.getException() and walkableGraph.isCycle(). Exception is null and cycle is false. If I run the command above on a different, but similar target I sometimes get this with no NPE:
However, if I put a shutdown command in between the build and aquery I get this.
From my perspective, I find the last case to match better what I expect to happen here. Something about the build command remains in the daemon in memory and affects the aquery. These aspect values, as long as they are not null, get dumped to the output. So, it appears that depending on the state of the bazel daemon you get different output. I suspect that there's another bug here since the output can sometimes contain this extra aspect, and other times not. I'm not sure if this could affect tools that are interpreting the protocol buffer output. |
Thanks for filing the issue. The NPE shouldn't be allowed to happen, there's a fix coming out today. The inconsistency you described is actually a known limitation of aquery (#14156). |
@bazel-io flag |
@bazel-io fork 6.2.0 |
This should have been included in unknown commit (which added the same check for text output). FIXES #15716. PiperOrigin-RevId: 525434548 Change-Id: I5fc80fa1f81ccf5f7b0d8b5d826d8418e2239306 Co-authored-by: Googler <leba@google.com>
This should have been included in unknown commit (which added the same check for text output). FIXES bazelbuild#15716. PiperOrigin-RevId: 525434548 Change-Id: I5fc80fa1f81ccf5f7b0d8b5d826d8418e2239306
Description of the bug:
When running an aquery on a target that was previously built with an aspect ("—aspects" command-line) and the same daemon process the following NullPointerException (NPE) occurs.
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
This bug is difficult to reproduce since it is intermittent and happens with a specific complex target in our environment. Here's a generalized template of the command that exhibits the problem in our environment.
Note: the foo_aspect is added for the bazel build, but not for the bazel aquery, which uses the bar_aspect.
The NPE does not occur if the aspect is not added to the original build. The output of the aquery must be proto, and not the default text output. Also, the NPE does not occur if the daemon is shut down in between the two commands like this.
Which operating system are you running Bazel on?
macOS 12.3
What is the output of
bazel info release
?5.1.1-8-g30432e50c5
If
bazel info release
returnsdevelopment 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 master; git rev-parse HEAD
?No response
Have you found anything relevant by searching the web?
This particular NPE does not appear to show up in the typical places.
Any other information, logs, or outputs that you want to share?
The text was updated successfully, but these errors were encountered: