Merge "Handle OutOfMemoryError from allocating InterruptedExceptions"
diff --git a/libart/src/main/java/java/lang/Daemons.java b/libart/src/main/java/java/lang/Daemons.java
index a6ac449..8542cf6 100644
--- a/libart/src/main/java/java/lang/Daemons.java
+++ b/libart/src/main/java/java/lang/Daemons.java
@@ -114,6 +114,8 @@
threadToStop.join();
return;
} catch (InterruptedException ignored) {
+ } catch (OutOfMemoryError ignored) {
+ // An OOME may be thrown if allocating the InterruptedException failed.
}
}
}
@@ -151,6 +153,8 @@
}
} catch (InterruptedException e) {
continue;
+ } catch (OutOfMemoryError e) {
+ continue;
}
enqueue(list);
}
@@ -184,6 +188,7 @@
try {
doFinalize((FinalizerReference<?>) queue.remove());
} catch (InterruptedException ignored) {
+ } catch (OutOfMemoryError ignored) {
}
}
}
@@ -256,6 +261,8 @@
} catch (InterruptedException e) {
// Daemon.stop may have interrupted us.
return false;
+ } catch (OutOfMemoryError e) {
+ return false;
}
}
}
@@ -275,6 +282,10 @@
if (!isRunning()) {
return;
}
+ } catch (OutOfMemoryError ignored) {
+ if (!isRunning()) {
+ return;
+ }
}
}
}
@@ -304,6 +315,8 @@
Thread.sleep(5000);
} catch (Exception e) {
System.logE("failed to send SIGQUIT", e);
+ } catch (OutOfMemoryError ignored) {
+ // May occur while trying to allocate the exception.
}
if (h == null) {
// If we have no handler, log and exit.