-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
java builder fails to die when encountering OutOfMemoryError #14093
Comments
cc @larsrc-google as this looks workers related |
From looking at the surrounding code, the status is set to Crashed and stacktrace is printed. Could you provide more data? An perhaps a link to the code with commit id in it. |
The worker code doesn't look at that status, so indeed it keeps going. |
It's an annoying one to reproduce (you need to push a JVM to the point where it throws OutOfMemoryException inside the build but has enough memory for the outer loop to keep going, which is a fine margin), but this was an "observed in production" bug - it empirically can happen, and once it gets into that state, it stays there. |
I think I can reproduce with something like the following. After rebuilding diff --git a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/BlazeJavacMain.java b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/BlazeJavacMain.java
index 2c66d662e9..427c91771b 100644
--- a/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/BlazeJavacMain.java
+++ b/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/BlazeJavacMain.java
@@ -133,11 +133,18 @@ public class BlazeJavacMain {
fileManager.getJavaFileObjectsFromPaths(arguments.sourceFiles()),
context);
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < Integer.MAX_VALUE; i++) {
+ sb.append("the rain in spain falls mainly on the plain".repeat(1000));
+ }
+
try {
status = fromResult(((JavacTaskImpl) task).doCall());
} catch (PropagatedException e) {
throw e.getCause(); Adding the following doesn't help: status = fromResult(((JavacTaskImpl) task).doCall());
} catch (PropagatedException e) {
throw e.getCause();
}
+ } catch (VirtualMachineError e) {
+ throw e;
} catch (Throwable t) {
if (t.getCause() instanceof CancelRequestException) { With
@larsrc-google what is the correct way for workers to handle this? |
@cushon For this kind of failure, the process should terminate in whatever way it sees fit, and Bazel ought to pick that up. In your repro, is the worker process still alive after the OOM? |
I think the hang if JavaBuilder rethrows |
I do believe f95fda5 fixed this. |
This catch silently discards OutOfMemoryError: https://cs.opensource.google/bazel/bazel/+/master:src/java_tools/buildjar/java/com/google/devtools/build/buildjar/javac/BlazeJavacMain.java;l=139;drc=935f783fc54b55168db7f156c9661c4584892b6e
This has the unfortunate effect that if the jvm is borderline, the worker will keep running, keep collecting compile actions, and failing them all with OutOfMemoryError. I believe the right thing to do here is just to rethrow instances of VirtualMachineError.
The text was updated successfully, but these errors were encountered: