From 873d55f80d9c5d7a903cf8b1226c7f5cd5520642 Mon Sep 17 00:00:00 2001 From: "bazel.build machine account" Date: Tue, 11 Jun 2024 17:58:00 -0400 Subject: [PATCH] [7.2.1] Fix an NPE with the compact execution log and coverage (#22713) Fixes this issue when collecting coverage with the compact execution log: ``` Caused by: java.lang.NullPointerException: Cannot invoke "com.google.devtools.build.lib.cmdline.Label.getCanonicalForm()" because the return value of "com.google.devtools.build.lib.actions.Spawn.getTargetLabel()" is null at com.google.devtools.build.lib.exec.CompactSpawnLogContext.logSpawn(CompactSpawnLogContext.java:216) at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:191) at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:118) at com.google.devtools.build.lib.exec.SpawnStrategyResolver.exec(SpawnStrategyResolver.java:45) at com.google.devtools.build.lib.bazel.coverage.CoverageReportActionBuilder$CoverageReportAction.execute(CoverageReportActionBuilder.java:136) at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.executeAction(SkyframeActionExecutor.java:1159) at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:1076) at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:165) at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:94) at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:573) at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:859) at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.computeInternal(ActionExecutionFunction.java:333) at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:171) at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:461) ``` Closes #22703. PiperOrigin-RevId: 642384421 Change-Id: I2c3805f5d5ba250274f8da45bdc53b56a87c5f6c Commit https://github.com/bazelbuild/bazel/commit/0dbfaccaf5bee5ea7f11c01db1fc0cd1ca7f3810 Co-authored-by: Fabian Meumertzheim --- .../devtools/build/lib/exec/CompactSpawnLogContext.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/devtools/build/lib/exec/CompactSpawnLogContext.java b/src/main/java/com/google/devtools/build/lib/exec/CompactSpawnLogContext.java index 69aa332fdd4332..9c5ee708b96386 100644 --- a/src/main/java/com/google/devtools/build/lib/exec/CompactSpawnLogContext.java +++ b/src/main/java/com/google/devtools/build/lib/exec/CompactSpawnLogContext.java @@ -213,7 +213,9 @@ public void logSpawn( builder.setInputSetId(logInputs(spawn, inputMetadataProvider, fileSystem)); builder.setToolSetId(logTools(spawn, inputMetadataProvider, fileSystem)); - builder.setTargetLabel(spawn.getTargetLabel().getCanonicalForm()); + if (spawn.getTargetLabel() != null) { + builder.setTargetLabel(spawn.getTargetLabel().getCanonicalForm()); + } builder.setMnemonic(spawn.getMnemonic()); for (ActionInput output : spawn.getOutputFiles()) {