8304939: os::win32::exit_process_or_thread should be marked noreturn

Reviewed-by: dholmes, kbarrett
This commit is contained in:
Julian Waters 2023-11-01 10:42:23 +00:00
parent 0461d9a7d6
commit b4f5379d50
4 changed files with 18 additions and 18 deletions

View File

@ -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<Thread*>(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?

View File

@ -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();

View File

@ -71,4 +71,5 @@ void VMError::raise_fail_fast(void* exrecord, void* context) {
RaiseFailFastException(static_cast<PEXCEPTION_RECORD>(exrecord),
static_cast<PCONTEXT>(context),
flags);
os::infinite_sleep();
}

View File

@ -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: