Skip to content

Commit b92c5a4

Browse files
committed
8265292: [macos_aarch64] java/foreign/TestDowncall.java crashes with SIGBUS
8265183: [macos_aarch64] java/foreign/TestIntrinsics.java crashes with SIGBUS 8265182: [macos_aarch64] java/foreign/TestUpcall.java crashes with SIGBUS Reviewed-by: dholmes
1 parent fadf580 commit b92c5a4

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/hotspot/share/prims/universalNativeInvoker.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ ProgrammableInvoker::Generator::Generator(CodeBuffer* code, const ABIDescriptor*
3131
_layout(layout) {}
3232

3333
void ProgrammableInvoker::invoke_native(Stub stub, address buff, JavaThread* thread) {
34-
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXExec, thread));
3534
ThreadToNativeFromVM ttnfvm(thread);
35+
// We need WXExec because we are about to call a generated stub. Like in VM
36+
// entries, the thread state should be changed while we are still in WXWrite.
37+
// See JDK-8265292.
38+
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXExec, thread));
3639
stub(buff);
3740
}
3841

src/hotspot/share/runtime/interfaceSupport.inline.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,14 @@ class VMNativeEntryWrapper {
290290

291291
// LEAF routines do not lock, GC or throw exceptions
292292

293+
// On macos/aarch64 we need to maintain the W^X state of the thread. So we
294+
// take WXWrite on the enter to VM from the "outside" world, so the rest of JVM
295+
// code can assume writing (but not executing) codecache is always possible
296+
// without preliminary actions.
297+
// JavaThread state should be changed only after taking WXWrite. The state
298+
// change may trigger a safepoint, that would need WXWrite to do bookkeeping
299+
// in the codecache.
300+
293301
#define VM_LEAF_BASE(result_type, header) \
294302
debug_only(NoHandleMark __hm;) \
295303
MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, \

test/jdk/ProblemList.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,6 @@ java/beans/XMLEncoder/Test6570354.java 8015593 macosx-all
543543
java/foreign/TestMismatch.java 8249684 macosx-all
544544

545545
java/foreign/StdLibTest.java 8263512 macosx-aarch64
546-
java/foreign/TestDowncall.java 8265292 macosx-aarch64
547-
java/foreign/TestIntrinsics.java 8265183 macosx-aarch64
548-
java/foreign/TestUpcall.java 8265182 macosx-aarch64
549546
java/foreign/TestVarArgs.java 8263512 macosx-aarch64
550547
java/foreign/valist/VaListTest.java 8263512 macosx-aarch64
551548

0 commit comments

Comments
 (0)