From b00720edd72226ae9ffecbcb9c1062d3ceb8c6df Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Fri, 10 Oct 2025 07:37:09 +0000 Subject: [PATCH] 8369419: Error reporting of JFR JNI method registration crash on MacOSX Reviewed-by: jbachorik, egahlin --- src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp b/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp index 63efb7404e4..2979f5c5c2d 100644 --- a/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp +++ b/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2025, Datadog, Inc. 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 @@ -27,6 +28,7 @@ #include "logging/log.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/javaThread.inline.hpp" +#include "runtime/threadWXSetters.inline.hpp" #include "utilities/exceptions.hpp" JfrJniMethodRegistration::JfrJniMethodRegistration(JNIEnv* env) { @@ -113,6 +115,7 @@ JfrJniMethodRegistration::JfrJniMethodRegistration(JNIEnv* env) { JavaThread* jt = JavaThread::thread_from_jni_environment(env); assert(jt != nullptr, "invariant"); assert(jt->thread_state() == _thread_in_native, "invariant"); + MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, jt)); ThreadInVMfromNative transition(jt); log_error(jfr, system)("RegisterNatives for JVM class failed!"); }