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

Missing file in hdrs attribute of cc_library rule causes a RuntimeException #8350

Closed
staalb opened this issue May 16, 2019 · 0 comments
Closed
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-CPP Issues for C++ rules type: bug

Comments

@staalb
Copy link

staalb commented May 16, 2019

Description of the problem:

Missing file in hdrs attribute of cc_library rule causes a RuntimeException instead of a proper error message. However, this only happens in a very specific case illustrated in the BUILD file below. I'm using two different toolchains (Visual Studio for local builds, a cross GCC toolchain for an ARM target). Only in case if the cc_library rule is reference from targets built by both toolchains this happens.

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

This was a hard one to isolate...

Create a workspace with empty WORKSPACE and BUILD files in the root folder. Add the following files:

In Bar/inc/lib.h

#include "lib_internal.h"

Bar/inc/lib_internal.h can be empty.

In Bar/lib.cpp:

#include "lib.h"

In Bar/test.cpp:

int main() {
    return 0;
}

Finally, in Bar/BUILD:

#
# This BUILD file has to be in a subdirectory of a workspace. The name of this
# directory has to start with a capital letter!
#
# Run the following commands to trigger the bug:
#   bazel clean --expunge
#   bazel test --compiler=msvc-cl //Bar:test
#   bazel build --compiler=mingw-gcc //Bar:lib
#
# It also works if the order of the last two commands is swapped.
#

cc_library(
    name = "iface",
    hdrs = ["inc/lib.h"],    # << lib_internal.h intentionally missing
    includes = ["inc"],
)

cc_library(
    name = "lib",
    srcs = ["lib.cpp"],
    deps = [":iface"]
)

cc_test(
    name = "test",
    srcs = ["test.cpp"],
    deps = [":lib", ":iface"],
)

The last commands mentioned in the comment in the BUILD file results in the following output:

D:\proj\issue_test>bazel test --compiler=msvc-cl //Bar:test
Starting local Bazel server and connecting to it...
INFO: Analyzed target //Bar:test (16 packages loaded, 321 targets configured).
INFO: Found 1 test target...
Target //Bar:test up-to-date:
  C:/users/staalb/_bazel_staalb/e66p4nz3/execroot/__main__/bazel-out/x64_windows-fastbuild/bin/Bar/test.exe
INFO: Elapsed time: 3.258s, Critical Path: 0.02s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
//Bar:test                                                      (cached) PASSED in 0.6s

Executed 0 out of 1 test: 1 test passes.
INFO: Build completed successfully, 1 total action

D:\proj\issue_test>bazel build --compiler=mingw-gcc //Bar:lib
INFO: Build option --compiler has changed, discarding analysis cache.
INFO: Analyzed target //Bar:lib (0 packages loaded, 79 targets configured).
INFO: Found 1 target...
Internal error thrown during build. Printing stack trace: java.lang.RuntimeException: Unrecoverable error while evaluating node 'ActionLookupData{actionLookupKey=//Bar:lib BuildConfigurationValue.Key[9a182ef07c8f7f6cecbe6cb67bfaa4e2] false, actionIndex=1}' (requested by nodes 'File:[[<execution_root>]bazel-out/x64_windows-fastbuild/bin]Bar/_objs/lib/lib.o')
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:530)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:387)
        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.IllegalStateException: null for File:[D:/proj/issue_test[source]]Bar/inc/lib_internal.h
        at com.google.devtools.build.lib.skyframe.ActionMetadataHandler.getMetadata(ActionMetadataHandler.java:184)
        at com.google.devtools.build.lib.actions.ActionCacheChecker.getMetadataOrConstant(ActionCacheChecker.java:317)
        at com.google.devtools.build.lib.actions.ActionCacheChecker.getMetadataMaybe(ActionCacheChecker.java:328)
        at com.google.devtools.build.lib.actions.ActionCacheChecker.updateActionCache(ActionCacheChecker.java:366)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.updateActionCache(SkyframeActionExecutor.java:674)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction$ActionPostprocessingImpl.run(ActionExecutionFunction.java:775)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner$ActionCacheWriteStep.run(SkyframeActionExecutor.java:1116)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:114)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:78)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:563)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:707)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:253)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:453)
        ... 4 more

INFO: Elapsed time: 0.372s, Critical Path: 0.09s
INFO: 1 process: 1 local.
FAILED: Build did NOT complete successfully
Internal error thrown during build. Printing stack trace: java.lang.RuntimeException: Unrecoverable error while evaluating node 'ActionLookupData{actionLookupKey=//Bar:lib BuildConfigurationValue.Key[9a182ef07c8f7f6cecbe6cb67bfaa4e2] false, actionIndex=1}' (requested by nodes 'File:[[<execution_root>]bazel-out/x64_windows-fastbuild/bin]Bar/_objs/lib/lib.o')
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:530)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:387)
        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.IllegalStateException: null for File:[D:/proj/issue_test[source]]Bar/inc/lib_internal.h
        at com.google.devtools.build.lib.skyframe.ActionMetadataHandler.getMetadata(ActionMetadataHandler.java:184)
        at com.google.devtools.build.lib.actions.ActionCacheChecker.getMetadataOrConstant(ActionCacheChecker.java:317)
        at com.google.devtools.build.lib.actions.ActionCacheChecker.getMetadataMaybe(ActionCacheChecker.java:328)
        at com.google.devtools.build.lib.actions.ActionCacheChecker.updateActionCache(ActionCacheChecker.java:366)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.updateActionCache(SkyframeActionExecutor.java:674)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction$ActionPostprocessingImpl.run(ActionExecutionFunction.java:775)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner$ActionCacheWriteStep.run(SkyframeActionExecutor.java:1116)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:114)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:78)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:563)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:707)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:253)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:453)
        ... 4 more
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ActionLookupData{actionLookupKey=//Bar:lib BuildConfigurationValue.Key[9a182ef07c8f7f6cecbe6cb67bfaa4e2] false, actionIndex=1}' (requested by nodes 'File:[[<execution_root>]bazel-out/x64_windows-fastbuild/bin]Bar/_objs/lib/lib.o')
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:530)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:387)
        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.IllegalStateException: null for File:[D:/proj/issue_test[source]]Bar/inc/lib_internal.h
        at com.google.devtools.build.lib.skyframe.ActionMetadataHandler.getMetadata(ActionMetadataHandler.java:184)
        at com.google.devtools.build.lib.actions.ActionCacheChecker.getMetadataOrConstant(ActionCacheChecker.java:317)
        at com.google.devtools.build.lib.actions.ActionCacheChecker.getMetadataMaybe(ActionCacheChecker.java:328)
        at com.google.devtools.build.lib.actions.ActionCacheChecker.updateActionCache(ActionCacheChecker.java:366)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.updateActionCache(SkyframeActionExecutor.java:674)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction$ActionPostprocessingImpl.run(ActionExecutionFunction.java:775)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner$ActionCacheWriteStep.run(SkyframeActionExecutor.java:1116)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:114)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:78)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:563)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:707)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:253)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:453)
        ... 4 more
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ActionLookupData{actionLookupKey=//Bar:lib BuildConfigurationValue.Key[9a182ef07c8f7f6cecbe6cb67bfaa4e2] false, actionIndex=1}' (requested by nodes 'File:[[<execution_root>]bazel-out/x64_windows-fastbuild/bin]Bar/_objs/lib/lib.o')
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:530)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:387)
        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.IllegalStateException: null for File:[D:/proj/issue_test[source]]Bar/inc/lib_internal.h
        at com.google.devtools.build.lib.skyframe.ActionMetadataHandler.getMetadata(ActionMetadataHandler.java:184)
        at com.google.devtools.build.lib.actions.ActionCacheChecker.getMetadataOrConstant(ActionCacheChecker.java:317)
        at com.google.devtools.build.lib.actions.ActionCacheChecker.getMetadataMaybe(ActionCacheChecker.java:328)
        at com.google.devtools.build.lib.actions.ActionCacheChecker.updateActionCache(ActionCacheChecker.java:366)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.updateActionCache(SkyframeActionExecutor.java:674)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction$ActionPostprocessingImpl.run(ActionExecutionFunction.java:775)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner$ActionCacheWriteStep.run(SkyframeActionExecutor.java:1116)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:114)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:78)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:563)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:707)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:253)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:453)
FAILED: Build did NOT complete successfully

What operating system are you running Bazel on?

Windows 10

What's the output of bazel info release?

release 0.25.1

Also works with 0.25.2.

Might not reproduce with 0.18.1, however I can't get mingw properly to work with that version.

Have you found anything relevant by searching the web?

Issues #7279 and #7247 mention the same kind of exception location, but for me they don't seem to be related.

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

If the last command is executed a second time, the build runs fine (although I would expect an error because lib_internal.h isn't mentioned in the hdrs attribute?)

@dslomov dslomov added team-Rules-CPP Issues for C++ rules untriaged labels May 17, 2019
@oquenchil oquenchil added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels May 31, 2019
@oquenchil oquenchil self-assigned this May 31, 2019
@sgowroji sgowroji added the stale Issues or PRs that are stale (no activity for 30 days) label Feb 16, 2023
@sgowroji sgowroji closed this as not planned Won't fix, can't repro, duplicate, stale Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-CPP Issues for C++ rules type: bug
Projects
None yet
Development

No branches or pull requests

5 participants