From b528ca81f5de8c7dc8a09584079c140a6d3182f7 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Fri, 31 Oct 2025 14:06:11 +0100 Subject: [PATCH] Improve logging for dynamic execution crashes --- .../lib/dynamic/DynamicSpawnStrategy.java | 20 +++++++++++-------- .../remote/merkletree/MerkleTreeComputer.java | 6 +++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/dynamic/DynamicSpawnStrategy.java b/src/main/java/com/google/devtools/build/lib/dynamic/DynamicSpawnStrategy.java index 9b0bd0d7e8bf4c..64faf1106f333b 100644 --- a/src/main/java/com/google/devtools/build/lib/dynamic/DynamicSpawnStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/dynamic/DynamicSpawnStrategy.java @@ -606,14 +606,18 @@ private static ImmutableList waitBranch( // for cancellation. Assume the latter here because if this was actually a user interrupt, // our own get() would have been interrupted as well. It makes no sense to propagate the // interrupt status across threads. - context - .getEventHandler() - .handle( - Event.info( - String.format( - "Caught InterruptedException from ExecutionException for %s branch of %s," - + " which may cause a crash.", - mode, getSpawnReadableId(branch.getSpawn())))); + if (options.debugSpawnScheduler) { + context + .getEventHandler() + .handle( + Event.info( + String.format( + "Caught InterruptedException from ExecutionException for %s branch of %s," + + " which may cause a crash:\n%s", + mode, + getSpawnReadableId(branch.getSpawn()), + Throwables.getStackTraceAsString(cause)))); + } return null; } else { // Even though we cannot enforce this in the future's signature (but we do in Branch#call), diff --git a/src/main/java/com/google/devtools/build/lib/remote/merkletree/MerkleTreeComputer.java b/src/main/java/com/google/devtools/build/lib/remote/merkletree/MerkleTreeComputer.java index f74a1c950235b7..1b3d14e72a08cf 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/merkletree/MerkleTreeComputer.java +++ b/src/main/java/com/google/devtools/build/lib/remote/merkletree/MerkleTreeComputer.java @@ -950,7 +950,11 @@ private static T getFromFuture(Future future) throws IOException, Interru future.cancel(/* mayInterruptIfRunning= */ true); throw e; } catch (CancellationException e) { - throw new InterruptedException(); + // TODO(b/173153395): Drop the cause when the crashes with dynamic execution have been + // diagnosed. + var interruptedException = new InterruptedException(); + interruptedException.initCause(e); + throw interruptedException; } catch (ExecutionException e) { if (e.getCause() instanceof WrappedException wrappedException) { wrappedException.unwrapAndThrow();