mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8322818: Thread::getStackTrace can fail with InternalError if virtual thread is timed-parked when pinned
Reviewed-by: pchilanomate
This commit is contained in:
parent
755722ced6
commit
4db7a1c3bb
2 changed files with 78 additions and 3 deletions
|
@ -975,12 +975,12 @@ final class VirtualThread extends BaseVirtualThread {
|
|||
* Returns null if the thread is mounted or in transition.
|
||||
*/
|
||||
private StackTraceElement[] tryGetStackTrace() {
|
||||
int initialState = state();
|
||||
int initialState = state() & ~SUSPENDED;
|
||||
switch (initialState) {
|
||||
case NEW, STARTED, TERMINATED -> {
|
||||
return new StackTraceElement[0]; // unmounted, empty stack
|
||||
}
|
||||
case RUNNING, PINNED -> {
|
||||
case RUNNING, PINNED, TIMED_PINNED -> {
|
||||
return null; // mounted
|
||||
}
|
||||
case PARKED, TIMED_PARKED -> {
|
||||
|
@ -992,7 +992,7 @@ final class VirtualThread extends BaseVirtualThread {
|
|||
case PARKING, TIMED_PARKING, YIELDING -> {
|
||||
return null; // in transition
|
||||
}
|
||||
default -> throw new InternalError();
|
||||
default -> throw new InternalError("" + initialState);
|
||||
}
|
||||
|
||||
// thread is unmounted, prevent it from continuing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue