8252521: possible race in java_suspend_self_with_safepoint_check
Reviewed-by: dholmes, rehn
This commit is contained in:
parent
ae5a6dde2d
commit
e25f2a5715
@ -2613,9 +2613,17 @@ int JavaThread::java_suspend_self() {
|
|||||||
void JavaThread::java_suspend_self_with_safepoint_check() {
|
void JavaThread::java_suspend_self_with_safepoint_check() {
|
||||||
assert(this == Thread::current(), "invariant");
|
assert(this == Thread::current(), "invariant");
|
||||||
JavaThreadState state = thread_state();
|
JavaThreadState state = thread_state();
|
||||||
set_thread_state(_thread_blocked);
|
|
||||||
java_suspend_self();
|
do {
|
||||||
set_thread_state_fence(state);
|
set_thread_state(_thread_blocked);
|
||||||
|
java_suspend_self();
|
||||||
|
// The current thread could have been suspended again. We have to check for
|
||||||
|
// suspend after restoring the saved state. Without this the current thread
|
||||||
|
// might return to _thread_in_Java and execute bytecodes for an arbitrary
|
||||||
|
// long time.
|
||||||
|
set_thread_state_fence(state);
|
||||||
|
} while (is_external_suspend());
|
||||||
|
|
||||||
// Since we are not using a regular thread-state transition helper here,
|
// Since we are not using a regular thread-state transition helper here,
|
||||||
// we must manually emit the instruction barrier after leaving a safe state.
|
// we must manually emit the instruction barrier after leaving a safe state.
|
||||||
OrderAccess::cross_modify_fence();
|
OrderAccess::cross_modify_fence();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user