From 83e9e482b181e76ca9f645e8cc83cfa9337df498 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Thu, 17 Oct 2024 18:06:42 +0000 Subject: [PATCH] 8325937: runtime/handshake/HandshakeDirectTest.java causes "monitor end should be strictly below the frame pointer" assertion failure on AArch64 Reviewed-by: rehn, eosterlund, pchilanomate, aph, fbredberg --- src/hotspot/share/runtime/handshake.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/runtime/handshake.cpp b/src/hotspot/share/runtime/handshake.cpp index 3919a89789c..20399452eb9 100644 --- a/src/hotspot/share/runtime/handshake.cpp +++ b/src/hotspot/share/runtime/handshake.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -251,8 +251,13 @@ class VM_HandshakeAllThreads: public VM_Operation { thr->handshake_state()->add_operation(_op); number_of_threads_issued++; } + + // Separate the arming of the poll in add_operation() above from + // the read of JavaThread state in the try_process() call below. if (UseSystemMemoryBarrier) { SystemMemoryBarrier::emit(); + } else { + OrderAccess::fence(); } if (number_of_threads_issued < 1) { @@ -380,6 +385,8 @@ void Handshake::execute(HandshakeClosure* hs_cl, ThreadsListHandle* tlh, JavaThr // the read of JavaThread state in the try_process() call below. if (UseSystemMemoryBarrier) { SystemMemoryBarrier::emit(); + } else { + OrderAccess::fence(); } // Keeps count on how many of own emitted handshakes @@ -559,6 +566,10 @@ bool HandshakeState::process_by_self(bool allow_suspend, bool check_async_except // Threads shouldn't block if they are in the middle of printing, but... ttyLocker::break_tty_lock_for_safepoint(os::current_thread_id()); + // Separate all the writes above for other threads reading state + // set by this thread in case the operation is ThreadSuspendHandshake. + OrderAccess::fence(); + while (has_operation()) { // Handshakes cannot safely safepoint. The exceptions to this rule are // the asynchronous suspension and unsafe access error handshakes.