summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Roland Levillain <rpl@google.com> 2018-01-04 13:11:52 +0000
committer Roland Levillain <rpl@google.com> 2018-01-04 14:24:39 +0000
commita81a374e2b5f8ec62b17afc73efff16b35c9ba61 (patch)
tree45bdafcc0a8ca3b100735a271bd405f979881c5d
parent3165bb09dc04b61abd04bf8e263dd85d610694e4 (diff)
Ignore OOMEs in ThreadStress' QueuedWait operation.
Previous work on ThreadStress' QueuedWait operation avoided some out-of-memory issues by by forcing ahead-of-time initialization of classes used by the Semaphore class (see https://android-review.googlesource.com/508595). However, the execution of code from the Semaphore can still throw an OutOfMemoryError as some of its code paths allocate memory. In that case (which is expected to be rare), just ignore the OOME and continue the execution. Test: art/test/testrunner/testrunner.py -t 004-ThreadStress Bug: 71570713 Change-Id: I0970e9cc768ce69c669ed75ade22961700ed4549
-rw-r--r--test/004-ThreadStress/src/Main.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/004-ThreadStress/src/Main.java b/test/004-ThreadStress/src/Main.java
index a9e0faf500..6ad160c1a6 100644
--- a/test/004-ThreadStress/src/Main.java
+++ b/test/004-ThreadStress/src/Main.java
@@ -267,6 +267,15 @@ public class Main implements Runnable {
semaphore.acquire();
permitAcquired = true;
Thread.sleep(SLEEP_TIME);
+ } catch (OutOfMemoryError ignored) {
+ // The call to semaphore.acquire() above may trigger an OOME,
+ // despite the care taken doing some warm-up by forcing
+ // ahead-of-time initialization of classes used by the Semaphore
+ // class (see forceTransitiveClassInitialization below).
+ // For instance, one of the code paths executes
+ // AbstractQueuedSynchronizer.addWaiter, which allocates an
+ // AbstractQueuedSynchronizer$Node (see b/67730573).
+ // In that case, just ignore the OOME and continue.
} catch (InterruptedException ignored) {
} finally {
if (permitAcquired) {