Skip to content

Commit

Permalink
Merge pull request #18101 from babsingh/update_shutdownsignalhandler
Browse files Browse the repository at this point in the history
(0.41) Don't invoke shutdown signal handler until JVM init completes
  • Loading branch information
pshipton authored Sep 8, 2023
2 parents 87d042a + 4676e0b commit 0999970
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions runtime/vm/jvminit.c
Original file line number Diff line number Diff line change
Expand Up @@ -7898,8 +7898,9 @@ predefinedHandlerWrapper(struct J9PortLibrary *portLibrary, U_32 gpType, void *g
J9JavaVMAttachArgs attachArgs = {0};
J9VMThread *vmThread = NULL;
IDATA result = JNI_ERR;
BOOLEAN shutdownStarted = FALSE;
BOOLEAN invokeHandler = TRUE;
I_32 signal = 0;
U_32 runtimeFlags = 0;
PORT_ACCESS_FROM_JAVAVM(vm);

signal = j9sig_map_portlib_signal_to_os_signal(gpType);
Expand All @@ -7908,14 +7909,16 @@ predefinedHandlerWrapper(struct J9PortLibrary *portLibrary, U_32 gpType, void *g
return 1;
}

/* Don't invoke handler if JVM exit has started. */
omrthread_monitor_enter(vm->runtimeFlagsMutex);
if (J9_ARE_ANY_BITS_SET(vm->runtimeFlags, J9_RUNTIME_EXIT_STARTED)) {
shutdownStarted = TRUE;
/* Don't invoke handler if JVM hasn't initialized or JVM exit has started. */
issueReadBarrier();
runtimeFlags = vm->runtimeFlags;
if (J9_ARE_NO_BITS_SET(runtimeFlags, J9_RUNTIME_INITIALIZED)
|| J9_ARE_ANY_BITS_SET(runtimeFlags, J9_RUNTIME_EXIT_STARTED)
) {
invokeHandler = FALSE;
}
omrthread_monitor_exit(vm->runtimeFlagsMutex);

if (shutdownStarted) {
if (!invokeHandler) {
return 1;
}

Expand Down

0 comments on commit 0999970

Please sign in to comment.