8330303: Crash: assert(_target_jt == nullptr || _target_jt->vthread() == target_h()) failed

Reviewed-by: pchilanomate, cjplummer, lmesnik
This commit is contained in:
Serguei Spitsyn 2024-04-24 11:43:49 +00:00
parent 2bb5cf5f33
commit 15190816f7
3 changed files with 11 additions and 4 deletions

@ -2076,7 +2076,9 @@ GetSingleStackTraceClosure::do_thread(Thread *target) {
void
GetSingleStackTraceClosure::do_vthread(Handle target_h) {
assert(_target_jt == nullptr || _target_jt->vthread() == target_h(), "sanity check");
// Use jvmti_vthread() instead of vthread() as target could have temporarily changed
// identity to carrier thread (see VirtualThread.switchToCarrierThread).
assert(_target_jt == nullptr || _target_jt->jvmti_vthread() == target_h(), "sanity check");
doit();
}

@ -506,7 +506,9 @@ public:
}
void do_vthread(Handle target_h) {
assert(_target_jt != nullptr, "sanity check");
assert(_target_jt->vthread() == target_h(), "sanity check");
// Use jvmti_vthread() instead of vthread() as target could have temporarily changed
// identity to carrier thread (see VirtualThread.switchToCarrierThread).
assert(_target_jt->jvmti_vthread() == target_h(), "sanity check");
doit(_target_jt); // mounted virtual thread
}
};
@ -526,7 +528,9 @@ public:
}
void do_vthread(Handle target_h) {
assert(_target_jt != nullptr, "sanity check");
assert(_target_jt->vthread() == target_h(), "sanity check");
// Use jvmti_vthread() instead of vthread() as target could have temporarily changed
// identity to carrier thread (see VirtualThread.switchToCarrierThread).
assert(_target_jt->jvmti_vthread() == target_h(), "sanity check");
doit(_target_jt); // mounted virtual thread
}
};

@ -298,7 +298,8 @@ class GetCurrentLocationClosure : public JvmtiUnitedHandshakeClosure {
}
void do_vthread(Handle target_h) {
assert(_target_jt == nullptr || !_target_jt->is_exiting(), "sanity check");
// use jvmti_vthread() as vthread() can be outdated
// Use jvmti_vthread() instead of vthread() as target could have temporarily changed
// identity to carrier thread (see VirtualThread.switchToCarrierThread).
assert(_target_jt == nullptr || _target_jt->jvmti_vthread() == target_h(), "sanity check");
ResourceMark rm;
javaVFrame *jvf = JvmtiEnvBase::get_vthread_jvf(target_h());