[jdk19] RFR: 8287847: Fatal Error when suspending virtual thread after it has terminated [v9]
Serguei Spitsyn
sspitsyn at openjdk.org
Sat Jul 2 09:13:41 UTC 2022
On Sat, 2 Jul 2022 06:30:13 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:
>> This fixes a bug in the debug agent when there is a request to suspend a virtual thread that has already terminated. The issue was that unless the debug agent was currently under a "suspend all", it would not properly put the virtual thread on the `otherThreads` list, and instead added it to `runningVThreads`. This meant at the end of `insertThread()` the following code tried to do a JVMTI `SetThreadLocalStorage`, which can't be done on a terminated thread.
>>
>>
>> if (list != &otherThreads) {
>> setThreadLocalStorage(node->thread, (void*)node);
>> }
>
> Chris Plummer has updated the pull request incrementally with one additional commit since the last revision:
>
> Rename thread to targetThread. Verify targetThread state when the thread dies and when the breakpoint after the join() is reached.
Chris,
I see the test SelfSuspendDisablerTest with my update failed in your sanity checks.
The problem is:
```
71 public static void main(String argv[]) throws Exception {
72 Thread t1 = Thread.ofPlatform().factory().newThread(() -> {
73 testJvmtiThreadState(Thread.currentThread(), RUNNABLE);
74 selfSuspend(); <== It does a self suspend here!!
75 });
76 Thread t2 = Thread.ofVirtual().factory().newThread(() -> {
77 testJvmtiThreadState(Thread.currentThread(), RUNNABLE);
78 while(!isSuspended(t1)) {
79 Thread.yield();
80 }
81 Thread.yield(); // provoke unmount
82
83 testJvmtiThreadState(t1, SUSPENDED);
84
85 resume(t1);
86
87 testJvmtiThreadState(t1, RUNNABLE); <== This is wrong because of line 74!!
88
89 suspendAllVirtualThreads();
90 });
The line 87 has to be removed.
Could, you remove the lines 87-88 as part of your PR?
It’d be the simplest way to handle it.
-------------
PR: https://git.openjdk.org/jdk19/pull/88
More information about the serviceability-dev
mailing list