forked from dragonwell-project/dragonwell17
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Wisp] Fix dead loop when killing threads waiting for objectmonitor.
Summary: Threads waiting for objectmonitor will skip calling WispTask::park when async exception is pending, so mannualy clear exception before WispThread::park Test Plan: jtreg test/jdk/com/alibaba/rcm/TestDeadLoopKillObjectMonitor.java Reviewed-by: yulei Issue: dragonwell-project#146
- Loading branch information
Showing
4 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
test/jdk/com/alibaba/rcm/TestDeadLoopKillObjectMonitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* @test | ||
* @library /test/lib | ||
* @build TestDeadLoopKillObjectMonitor RcmUtils | ||
* @summary test RCM TestKillThreads | ||
* @modules java.base/com.alibaba.wisp.engine:+open | ||
* @modules java.base/com.alibaba.rcm.internal:+open | ||
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+UseWisp2 -XX:+Wisp2ThreadStop -XX:ActiveProcessorCount=1 TestDeadLoopKillObjectMonitor | ||
*/ | ||
|
||
import com.alibaba.rcm.Constraint; | ||
import com.alibaba.rcm.ResourceContainer; | ||
import com.alibaba.rcm.ResourceType; | ||
import com.alibaba.rcm.internal.RCMUnsafe; | ||
import com.alibaba.wisp.engine.WispResourceContainerFactory; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Collections; | ||
import java.util.concurrent.CountDownLatch; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
|
||
public class TestDeadLoopKillObjectMonitor { | ||
|
||
private static Object obj = new Object(); | ||
|
||
public static void main(String[] args) throws Exception { | ||
ResourceContainer container = RcmUtils.createContainer(Collections.singletonList( | ||
ResourceType.CPU_PERCENT.newConstraint(100))); | ||
|
||
CountDownLatch latch = new CountDownLatch(1); | ||
Thread t1 = new Thread(new Runnable() { | ||
@Override | ||
public void run() { | ||
synchronized (obj) { | ||
try { | ||
Thread.sleep(1000); | ||
Thread t2 = new Thread(new Runnable() { | ||
@Override | ||
public void run() { | ||
latch.countDown(); | ||
} | ||
}); | ||
t2.setDaemon(true); | ||
t2.start(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
}); | ||
t1.setDaemon(true); | ||
t1.start(); | ||
|
||
Thread.sleep(100); | ||
container.run(() -> { | ||
Thread t = new Thread(new Runnable() { | ||
@Override | ||
public void run() { | ||
while (true) | ||
synchronized (obj) { | ||
System.out.println("rr"); | ||
} | ||
} | ||
}); | ||
t.start(); | ||
}); | ||
|
||
Thread.sleep(100); | ||
RCMUnsafe.killThreads(container); | ||
} | ||
|
||
} |