-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8306324: StopThread results in thread being marked as interrupted, leading to unexpected InterruptedException #26365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
cd23546
8338fb5
fde881f
1f7b67c
a46ef6f
476665c
11bc5a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1146,7 +1146,6 @@ void JavaThread::install_async_exception(AsyncExceptionHandshakeClosure* aehc) { | |
oop vt_oop = vthread(); | ||
if (vt_oop == nullptr || !vt_oop->is_a(vmClasses::BaseVirtualThread_klass())) { | ||
// Interrupt thread so it will wake up from a potential wait()/sleep()/park() | ||
java_lang_Thread::set_interrupted(threadObj(), true); | ||
this->interrupt(); | ||
} | ||
} | ||
|
@@ -2098,7 +2097,7 @@ bool JavaThread::sleep(jlong millis) { | |
|
||
// java.lang.Thread.sleep support | ||
// Returns true if sleep time elapsed as expected, and false | ||
// if the thread was interrupted. | ||
// if the thread was interrupted or async exception was installed. | ||
bool JavaThread::sleep_nanos(jlong nanos) { | ||
assert(this == Thread::current(), "thread consistency check"); | ||
assert(nanos >= 0, "nanos are in range"); | ||
|
@@ -2118,6 +2117,9 @@ bool JavaThread::sleep_nanos(jlong nanos) { | |
jlong nanos_remaining = nanos; | ||
|
||
for (;;) { | ||
if (has_async_exception_condition()) { | ||
return false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good suggestion, addressed now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The mach5 tiers 1-6 are good with the latest pushes. |
||
} | ||
// interruption has precedence over timing out | ||
if (this->is_interrupted(true)) { | ||
return false; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not for this bug but we have this
HAS_PENDING_EXCEPTION
check here and further up but I don't see how we can have a pending exception when calling this method. Based on the comment here seems we just wanted to check the async ones as added now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we always have
HAS_PENDING_EXCEPTION == true
if async exception was installed?If so, then this newly added check is not really needed:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until we process the async exception handshake operation,
HAS_PENDING_EXCEPTION
will be false. The only way forHAS_PENDING_EXCEPTION
to be true would be if we already entered the method with a pending exception, but I don’t see how that is possible.