Skip to content

Commit f142470

Browse files
author
David Holmes
committed
8311981: Test gc/stringdedup/TestStringDeduplicationAgeThreshold.java#ZGenerational timed out
Reviewed-by: stefank, pchilanomate, dcubed, rehn
1 parent 595fdd3 commit f142470

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/hotspot/share/runtime/handshake.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,17 @@ HandshakeOperation* HandshakeState::get_op_for_self(bool allow_suspend, bool che
497497
}
498498

499499
bool HandshakeState::has_operation(bool allow_suspend, bool check_async_exception) {
500-
MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
501-
return get_op_for_self(allow_suspend, check_async_exception) != nullptr;
500+
// We must not block here as that could lead to deadlocks if we already hold an
501+
// "external" mutex. If the try_lock fails then we assume that there is an operation
502+
// and force the caller to check more carefully in a safer context. If we can't get
503+
// the lock it means another thread is trying to handshake with us, so it can't
504+
// happen during thread termination and destruction.
505+
bool ret = true;
506+
if (_lock.try_lock()) {
507+
ret = get_op_for_self(allow_suspend, check_async_exception) != nullptr;
508+
_lock.unlock();
509+
}
510+
return ret;
502511
}
503512

504513
bool HandshakeState::has_async_exception_operation() {

0 commit comments

Comments
 (0)