Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8262894: [macos_aarch64] SIGBUS in Assembler::ld_st2 #3241

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/hotspot/share/prims/jni.cpp
Expand Up @@ -3723,6 +3723,10 @@ static jint JNICALL jni_DestroyJavaVM_inner(JavaVM *vm) {

// Since this is not a JVM_ENTRY we have to set the thread state manually before entering.
JavaThread* thread = JavaThread::current();

// We are going to VM, change W^X state to the expected one.
MACOS_AARCH64_ONLY(WXMode oldmode = thread->enable_wx(WXWrite));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to save old state - see below.


ThreadStateTransition::transition_from_native(thread, _thread_in_vm);
if (Threads::destroy_vm()) {
// Should not change thread state, VM is gone
Expand All @@ -3731,6 +3735,7 @@ static jint JNICALL jni_DestroyJavaVM_inner(JavaVM *vm) {
return res;
} else {
ThreadStateTransition::transition(thread, _thread_in_vm, _thread_in_native);
MACOS_AARCH64_ONLY(thread->enable_wx(oldmode));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually unnecessary as Threads::destroy_vm never returns anything but true (we should change it to a void method and clean this up). If it were to fail you would have to know at what point it failed to determine whether you can actually touch the current thread any more.

res = JNI_ERR;
return res;
}
Expand Down Expand Up @@ -3910,6 +3915,9 @@ jint JNICALL jni_DetachCurrentThread(JavaVM *vm) {
return JNI_ERR;
}

// We are going to VM, change W^X state to the expected one.
MACOS_AARCH64_ONLY(thread->enable_wx(WXWrite));

// Safepoint support. Have to do call-back to safepoint code, if in the
// middle of a safepoint operation
ThreadStateTransition::transition_from_native(thread, _thread_in_vm);
Expand Down