diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/FileSystemValueCheckerInferringAncestors.java b/src/main/java/com/google/devtools/build/lib/skyframe/FileSystemValueCheckerInferringAncestors.java index fd905a35929919..6b2f276dfabc96 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/FileSystemValueCheckerInferringAncestors.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/FileSystemValueCheckerInferringAncestors.java @@ -165,6 +165,10 @@ private ImmutableDiff processEntries(int nThreads) ImmutableList> futures = nodeStates.entrySet().stream() .filter(e -> e.getValue().childrenToProcess.get() == 0) + // Materialize all leaves before scheduling them -- otherwise, we could race with the + // processing code which decrements childrenToProcess. + .collect(toImmutableList()) + .stream() .map( e -> executor.submit(