summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Light <allight@google.com> 2017-10-12 13:51:18 -0700
committer Alex Light <allight@google.com> 2017-10-12 13:59:15 -0700
commita44d514dde6fc29d99ecc31fe4bdb17b2e93b6c0 (patch)
treec7d7b8d0974ebe3d01ee13d82f8f7a42ee8d9de1
parent9ca5363e3b7e7f330037fb21412c0199cf4fc53e (diff)
Make StopRecur test hardened against move-exception
In some circumstances a StopThread call can occur just before a move-exception instruction. In this case the stopThread exception can be cleared unintentionally. Test: stress --cpu 60 Test: ./test/run-test --host --gcstress 1934 Bug: 67576489 Change-Id: Ia06baedf64ff41cc7be78750d4dd4543b8ff50d2
-rw-r--r--test/1934-jvmti-signal-thread/info.txt2
-rw-r--r--test/1934-jvmti-signal-thread/src/art/Test1934.java14
2 files changed, 13 insertions, 3 deletions
diff --git a/test/1934-jvmti-signal-thread/info.txt b/test/1934-jvmti-signal-thread/info.txt
index c8c91893e5..1c5867498f 100644
--- a/test/1934-jvmti-signal-thread/info.txt
+++ b/test/1934-jvmti-signal-thread/info.txt
@@ -1,3 +1,3 @@
Tests basic functions in the jvmti plugin.
-Tests that the GetBytecodes function works as expected.
+Tests that the StopThread and InterruptThread functions work as expected.
diff --git a/test/1934-jvmti-signal-thread/src/art/Test1934.java b/test/1934-jvmti-signal-thread/src/art/Test1934.java
index 552570a436..3e97b20bce 100644
--- a/test/1934-jvmti-signal-thread/src/art/Test1934.java
+++ b/test/1934-jvmti-signal-thread/src/art/Test1934.java
@@ -195,8 +195,18 @@ public class Test1934 {
target.start();
sem.acquire();
System.out.println("stopping other thread recurring");
- Threads.stopThread(target, new Error("AWESOME!"));
- target.join();
+ do {
+ // Due to the fact that dex has a specific instruction to get the current exception it is
+ // possible for the 'stop-thread' to be unintentionally caught. We just retry in this case.
+ try {
+ Threads.stopThread(target, new Error("AWESOME!"));
+ } catch (Exception e) {
+ // If we just missed the thread dying we would get a JVMTI_ERROR_THREAD_NOT_ALIVE so we
+ // catch that here.
+ }
+ // Wait for 1 second.
+ target.join(1000);
+ } while (target.isAlive());
System.out.println("Other thread Stopped by: " + out_err[0]);
if (PRINT_STACK_TRACE && out_err[0] != null) {
out_err[0].printStackTrace();