-
Notifications
You must be signed in to change notification settings - Fork 728
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
Don't invoke shutdown signal handler until JVM init completes #18085
Conversation
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signal handlers should not incorporate lock operations since they are not signal-safe. I have replaced the lock with a read barrier to read the most up-to-date vm->runtimeFlags
value.
Running a personal build to check if there are any side-effects. I will move the PR out of the draft state once the personal build looks good. @gacholio Requesting your review. @pshipton @tajila fyi, this is related to internal issue 148771. |
The personal build looks good; no side-effects seen. This PR is ready to be reviewed. |
jenkins test sanity zlinux jdk21 |
jenkins compile win jdk8 |
JVM init path: J9_CreateJavaVM. JVM exit paths: protectedDestroyJavaVM and exitJavaVM. A segfault or other side-effects can happen if the JVM init and exit paths execute concurrently. The exit path can be taken if a shutdown signal is raised and the shutdown handler is invoked. JVM shutdown signals are SIGINT, SIGTERM and SIGHUP. Preventing invocation of the exit path from the shutdown signal handler until the JVM initialization completes resolves the above side-effects. Related: - eclipse-openj9#17101 - eclipse-openj9#17438 Signed-off-by: Babneet Singh <[email protected]>
6d73779
to
d4dfa6c
Compare
Accidentally pushed into this PR. The impact of the accidental push has been reverted. Old PR builds:
|
JVM init path:
J9_CreateJavaVM
.JVM exit paths:
protectedDestroyJavaVM
andexitJavaVM
.A segfault or other side-effects can happen if the JVM init and
exit paths execute concurrently.
The exit path can be taken if a shutdown signal is raised and the
shutdown handler is invoked. JVM shutdown signals are
SIGINT
,SIGTERM
and
SIGHUP
.Preventing invocation of the exit path from the shutdown signal handler
until the JVM initialization completes resolves the above side-effects.
Related: