diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 802054ff9a2..bb3e47050b2 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -505,12 +505,17 @@ struct tm* os::gmtime_pd(const time_t* clock, struct tm* res) { return nullptr; } +enum Ept { EPT_THREAD, EPT_PROCESS, EPT_PROCESS_DIE }; +// Wrapper around _endthreadex(), exit() and _exit() +[[noreturn]] +static void exit_process_or_thread(Ept what, int code); + JNIEXPORT LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo); // Thread start routine for all newly created threads. // Called with the associated Thread* as the argument. -unsigned __stdcall os::win32::thread_native_entry(void* t) { +static unsigned __stdcall thread_native_entry(void* t) { Thread* thread = static_cast(t); thread->record_stack_base_and_size(); @@ -558,7 +563,8 @@ unsigned __stdcall os::win32::thread_native_entry(void* t) { // Thread must not return from exit_process_or_thread(), but if it does, // let it proceed to exit normally - return (unsigned)os::win32::exit_process_or_thread(os::win32::EPT_THREAD, res); + exit_process_or_thread(EPT_THREAD, res); + return res; } static OSThread* create_os_thread(Thread* thread, HANDLE thread_handle, @@ -745,7 +751,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, thread_handle = (HANDLE)_beginthreadex(nullptr, (unsigned)stack_size, - &os::win32::thread_native_entry, + &thread_native_entry, thread, initflag, &thread_id); @@ -1202,7 +1208,7 @@ void os::abort(bool dump_core, void* siginfo, const void* context) { if (dumpFile != nullptr) { CloseHandle(dumpFile); } - win32::exit_process_or_thread(win32::EPT_PROCESS, 1); + exit_process_or_thread(EPT_PROCESS, 1); } dumpType = (MINIDUMP_TYPE)(MiniDumpWithFullMemory | MiniDumpWithHandleData | @@ -1226,12 +1232,12 @@ void os::abort(bool dump_core, void* siginfo, const void* context) { jio_fprintf(stderr, "Call to MiniDumpWriteDump() failed (Error 0x%x)\n", GetLastError()); } CloseHandle(dumpFile); - win32::exit_process_or_thread(win32::EPT_PROCESS, 1); + exit_process_or_thread(EPT_PROCESS, 1); } // Die immediately, no exit hook, no abort hook, no cleanup. void os::die() { - win32::exit_process_or_thread(win32::EPT_PROCESS_DIE, -1); + exit_process_or_thread(EPT_PROCESS_DIE, -1); } void os::dll_unload(void *lib) { @@ -4097,7 +4103,7 @@ static BOOL CALLBACK init_crit_sect_call(PINIT_ONCE, PVOID pcrit_sect, PVOID*) { return TRUE; } -int os::win32::exit_process_or_thread(Ept what, int exit_code) { +static void exit_process_or_thread(Ept what, int exit_code) { // Basic approach: // - Each exiting thread registers its intent to exit and then does so. // - A thread trying to terminate the process must wait for all @@ -4275,7 +4281,7 @@ int os::win32::exit_process_or_thread(Ept what, int exit_code) { } // Should not reach here - return exit_code; + os::infinite_sleep(); } #undef EXIT_TIMEOUT @@ -4853,11 +4859,11 @@ ssize_t os::pd_write(int fd, const void *buf, size_t nBytes) { } void os::exit(int num) { - win32::exit_process_or_thread(win32::EPT_PROCESS, num); + exit_process_or_thread(EPT_PROCESS, num); } void os::_exit(int num) { - win32::exit_process_or_thread(win32::EPT_PROCESS_DIE, num); + exit_process_or_thread(EPT_PROCESS_DIE, num); } // Is a (classpath) directory empty? diff --git a/src/hotspot/os/windows/os_windows.hpp b/src/hotspot/os/windows/os_windows.hpp index 2f90da71554..5bf402069f3 100644 --- a/src/hotspot/os/windows/os_windows.hpp +++ b/src/hotspot/os/windows/os_windows.hpp @@ -70,13 +70,6 @@ class os::win32 { static HINSTANCE load_Windows_dll(const char* name, char *ebuf, int ebuflen); private: - // The handler passed to _beginthreadex(). - // Called with the associated Thread* as the argument. - static unsigned __stdcall thread_native_entry(void*); - - enum Ept { EPT_THREAD, EPT_PROCESS, EPT_PROCESS_DIE }; - // Wrapper around _endthreadex(), exit() and _exit() - static int exit_process_or_thread(Ept what, int exit_code); static void initialize_performance_counter(); diff --git a/src/hotspot/os/windows/vmError_windows.cpp b/src/hotspot/os/windows/vmError_windows.cpp index 2443246f5e5..c149a7f4c37 100644 --- a/src/hotspot/os/windows/vmError_windows.cpp +++ b/src/hotspot/os/windows/vmError_windows.cpp @@ -71,4 +71,5 @@ void VMError::raise_fail_fast(void* exrecord, void* context) { RaiseFailFastException(static_cast(exrecord), static_cast(context), flags); + os::infinite_sleep(); } diff --git a/src/hotspot/share/utilities/vmError.hpp b/src/hotspot/share/utilities/vmError.hpp index 88ba476891e..d5d4279bb0b 100644 --- a/src/hotspot/share/utilities/vmError.hpp +++ b/src/hotspot/share/utilities/vmError.hpp @@ -144,7 +144,7 @@ class VMError : public AllStatic { static jlong get_step_start_time(); static void clear_step_start_time(); - WINDOWS_ONLY(ATTRIBUTE_NORETURN static void raise_fail_fast(void* exrecord, void* context);) + WINDOWS_ONLY([[noreturn]] static void raise_fail_fast(void* exrecord, void* context);) public: