Skip to content

Commit 436d04d

Browse files
joelebacopybara-github
authored andcommitted
Fix a bug with non-execution phase errors being considered
UndetailedExecutionCause. Also, send a bug report for actual undetailed execution errors, instead of just logging. PiperOrigin-RevId: 439253033
1 parent 93677c6 commit 436d04d

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

src/main/java/com/google/devtools/build/lib/skyframe/SkyframeAnalysisAndExecutionResult.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
import com.google.devtools.build.lib.skyframe.AspectKeyCreator.AspectKey;
2424
import com.google.devtools.build.lib.util.DetailedExitCode;
2525
import com.google.devtools.build.skyframe.WalkableGraph;
26+
import javax.annotation.Nullable;
2627

2728
/** Encapsulates the raw analysis result of top level targets and aspects coming from Skyframe. */
2829
public final class SkyframeAnalysisAndExecutionResult extends SkyframeAnalysisResult {
29-
private final DetailedExitCode representativeExecutionExitCode;
30+
@Nullable private final DetailedExitCode representativeExecutionExitCode;
3031

3132
private SkyframeAnalysisAndExecutionResult(
3233
boolean hasLoadingError,
@@ -48,6 +49,7 @@ private SkyframeAnalysisAndExecutionResult(
4849
this.representativeExecutionExitCode = representativeExecutionExitCode;
4950
}
5051

52+
@Nullable
5153
public DetailedExitCode getRepresentativeExecutionExitCode() {
5254
return representativeExecutionExitCode;
5355
}
@@ -96,7 +98,7 @@ public static SkyframeAnalysisAndExecutionResult withErrors(
9698
WalkableGraph walkableGraph,
9799
ImmutableMap<AspectKey, ConfiguredAspect> aspects,
98100
PackageRoots packageRoots,
99-
DetailedExitCode representativeExecutionExitCode) {
101+
@Nullable DetailedExitCode representativeExecutionExitCode) {
100102
return new SkyframeAnalysisAndExecutionResult(
101103
hasLoadingError,
102104
hasAnalysisError,

src/main/java/com/google/devtools/build/lib/skyframe/SkyframeErrorProcessor.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ static ErrorProcessingResult processErrors(
166166
// turns out to be with execution.
167167
boolean hasAnalysisError = true;
168168
ViewCreationFailedException noKeepGoingAnalysisExceptionAspect = null;
169-
DetailedExitCode detailedExitCode = null;
170-
Throwable undetailedCause = null;
169+
DetailedExitCode representativeExecutionDetailedExitCode = null;
171170
Map<ActionAnalysisMetadata, ConflictException> actionConflicts = new HashMap<>();
172171
for (Map.Entry<SkyKey, ErrorInfo> errorEntry : result.errorMap().entrySet()) {
173172
SkyKey errorKey = getErrorKey(errorEntry);
@@ -275,17 +274,21 @@ static ErrorProcessingResult processErrors(
275274
actionConflicts.putAll(tlce.getTransitiveActionConflicts());
276275
continue;
277276
} else if (isExecutionException(cause)) {
278-
detailedExitCode =
277+
DetailedExitCode detailedExitCode = DetailedException.getDetailedExitCode(cause);
278+
if (detailedExitCode == null) {
279+
detailedExitCode = createDetailedExitCodeForUndetailedExecutionCause(result, cause);
280+
}
281+
representativeExecutionDetailedExitCode =
279282
DetailedExitCodeComparator.chooseMoreImportantWithFirstIfTie(
280-
detailedExitCode, ((DetailedException) cause).getDetailedExitCode());
283+
representativeExecutionDetailedExitCode, detailedExitCode);
281284
rootCauses =
282285
cause instanceof ActionExecutionException
283286
? ((ActionExecutionException) cause).getRootCauses()
284287
: NestedSetBuilder.emptySet(Order.STABLE_ORDER);
285288
hasAnalysisError = false;
286289
} else {
287-
// TODO(ulfjack): Report something!
288-
undetailedCause = cause;
290+
BugReport.logUnexpected(
291+
cause, "Unexpected cause encountered while evaluating: %s", errorKey);
289292
}
290293

291294
if (!inTest) {
@@ -325,12 +328,11 @@ static ErrorProcessingResult processErrors(
325328
throw noKeepGoingAnalysisExceptionAspect;
326329
}
327330

328-
if (includeExecutionPhase && detailedExitCode == null) {
329-
detailedExitCode = createDetailedExitCodeForUndetailedExecutionCause(result, undetailedCause);
330-
}
331-
332331
return ErrorProcessingResult.create(
333-
hasLoadingError, hasAnalysisError, ImmutableMap.copyOf(actionConflicts), detailedExitCode);
332+
hasLoadingError,
333+
hasAnalysisError,
334+
ImmutableMap.copyOf(actionConflicts),
335+
representativeExecutionDetailedExitCode);
334336
}
335337

336338
private static SkyKey getErrorKey(Entry<SkyKey, ErrorInfo> errorEntry) {
@@ -631,14 +633,14 @@ static void rethrow(
631633

632634
private static DetailedExitCode createDetailedExitCodeForUndetailedExecutionCause(
633635
EvaluationResult<?> result, Throwable undetailedCause) {
634-
// TODO(b/227660368): These warning logs should be a bug report, but tests currently fail.
635636
if (undetailedCause == null) {
636-
logger.atWarning().log("No exceptions found despite error in %s", result);
637+
BugReport.sendBugReport("No exceptions found despite error in %s", result);
637638
return createDetailedExecutionExitCode(
638639
"keep_going execution failed without an action failure",
639640
Execution.Code.NON_ACTION_EXECUTION_FAILURE);
640641
}
641-
logger.atWarning().withCause(undetailedCause).log("No detailed exception found in %s", result);
642+
BugReport.sendBugReport(
643+
new IllegalStateException("No detailed exception found in " + result, undetailedCause));
642644
return createDetailedExecutionExitCode(
643645
"keep_going execution failed without an action failure: "
644646
+ undetailedCause.getMessage()

0 commit comments

Comments
 (0)