Skip to content

Commit f6fb01b

Browse files
committed
8262903: [macos_aarch64] Thread::current() called on detached thread
1 parent a72f683 commit f6fb01b

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

src/hotspot/share/gc/shared/barrierSetNMethod.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ bool BarrierSetNMethod::supports_entry_barrier(nmethod* nm) {
5151
int BarrierSetNMethod::nmethod_stub_entry_barrier(address* return_address_ptr) {
5252
// Enable WXWrite: the function is called directly from nmethod_entry_barrier
5353
// stub.
54-
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite));
54+
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, Thread::current()));
5555

5656
address return_address = *return_address_ptr;
5757
CodeBlob* cb = CodeCache::find_blob(return_address);

src/hotspot/share/prims/unsafe.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,14 @@ UNSAFE_LEAF (void, Unsafe_WriteBack0(JNIEnv *env, jobject unsafe, jlong line)) {
459459
}
460460
#endif
461461

462-
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXExec));
462+
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXExec, Thread::current()));
463463
assert(StubRoutines::data_cache_writeback() != NULL, "sanity");
464464
(StubRoutines::DataCacheWriteback_stub())(addr_from_java(line));
465465
} UNSAFE_END
466466

467467
static void doWriteBackSync0(bool is_pre)
468468
{
469-
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXExec));
469+
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXExec, Thread::current()));
470470
assert(StubRoutines::data_cache_writeback_sync() != NULL, "sanity");
471471
(StubRoutines::DataCacheWritebackSync_stub())(is_pre);
472472
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ class VMNativeEntryWrapper {
336336

337337
#define VM_LEAF_BASE(result_type, header) \
338338
debug_only(NoHandleMark __hm;) \
339-
MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite)); \
339+
MACOS_AARCH64_ONLY(ThreadWXEnable __wx(WXWrite, \
340+
Thread::current())); \
340341
os::verify_stack_alignment(); \
341342
/* begin of body */
342343

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
// to be valid. If the load causes a fault, the error value is returned.
3333
inline int SafeFetch32(int* adr, int errValue) {
3434
assert(StubRoutines::SafeFetch32_stub(), "stub not yet generated");
35-
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXExec));
35+
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXExec, Thread::current()));
3636
return StubRoutines::SafeFetch32_stub()(adr, errValue);
3737
}
3838

3939
inline intptr_t SafeFetchN(intptr_t* adr, intptr_t errValue) {
4040
assert(StubRoutines::SafeFetchN_stub(), "stub not yet generated");
41-
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXExec));
41+
MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXExec, Thread::current()));
4242
return StubRoutines::SafeFetchN_stub()(adr, errValue);
4343
}
4444

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ class ThreadWXEnable {
3232
Thread* _thread;
3333
WXMode _old_mode;
3434
public:
35-
ThreadWXEnable(WXMode new_mode, Thread* thread = NULL) :
36-
_thread(thread ? thread : Thread::current()),
37-
_old_mode(_thread->enable_wx(new_mode))
35+
ThreadWXEnable(WXMode new_mode, Thread* thread) :
36+
_thread(thread),
37+
_old_mode(_thread ? _thread->enable_wx(new_mode) : WXWrite)
3838
{ }
3939
~ThreadWXEnable() {
40-
_thread->enable_wx(_old_mode);
40+
if (_thread) {
41+
_thread->enable_wx(_old_mode);
42+
}
4143
}
4244
};
4345
#endif // __APPLE__ && AARCH64

0 commit comments

Comments
 (0)