-
Notifications
You must be signed in to change notification settings - Fork 96
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
SapMachine #1901: Feature Request to allow service to crash if direct memory is OOM #1916
base: sapmachine
Are you sure you want to change the base?
Conversation
…ect memory is OOM
Hello @ansteiner, this pull request fulfills all formal requirements. |
src/hotspot/share/prims/unsafe.cpp
Outdated
@@ -478,6 +478,12 @@ UNSAFE_LEAF (void, Unsafe_WriteBackPostSync0(JNIEnv *env, jobject unsafe)) { | |||
doWriteBackSync0(false); | |||
} UNSAFE_END | |||
|
|||
// SapMachine 2025-02-05: Report error for DirectByteBufferOom to exit the VM | |||
UNSAFE_LEAF (void, Unsafe_ReportJavaOutOfMemory0(JNIEnv *env, jobject unsafe,jstring message)) { | |||
char *utf_message = java_lang_String::as_utf8_string(JNIHandles::resolve_non_null(message)); |
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.
On other usage of java_lang_String::as_utf8_string
I see a ResourceMark usage, seems this is missing here.
test/hotspot/jtreg/runtime/ErrorHandling/TestExitOnDirectOutOfMemoryError.java
Outdated
Show resolved
Hide resolved
test/hotspot/jtreg/runtime/ErrorHandling/TestExitOnDirectOutOfMemoryError.java
Outdated
Show resolved
Hide resolved
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.
Looks good overall. I made a few suggestions. Also, the new test is failing because the VM seems to exit with a different rc.
Hello @ansteiner, this pull request fulfills all formal requirements. |
Hello @ansteiner, this pull request fulfills all formal requirements. |
OK, we need to figure out what happens in the test. |
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.
The type of the entry is wrong.
@@ -478,6 +478,12 @@ UNSAFE_LEAF (void, Unsafe_WriteBackPostSync0(JNIEnv *env, jobject unsafe)) { | |||
doWriteBackSync0(false); | |||
} UNSAFE_END | |||
|
|||
// SapMachine 2025-02-05: Report error for DirectMemoryOom to exit the VM | |||
UNSAFE_LEAF (void, Unsafe_ReportJavaOutOfMemory0(JNIEnv *env, jobject unsafe, jstring message)) { |
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.
This should be UNSAFE_ENTRY instead of UNSAFE_LEAF
If the direct memory buffer run into OOM, DirectByteBuffer allocation code can notify the jvm if the system property "jdk.nio.reportErrorOnDirectMemoryOom" is set.
Benefits:
Crash/ExitOnOutOfMemoryError
allows a app/JVM that can no longer provide services and application code is handling the OOM of DirectByteBuffer to crash/exit and enabling the service to restart.HeapDumpOnOutOfMemoryError
option.Implementation with some minor adaptions from closed issue/PR from OpenJDK: openjdk/jdk#16176
fixes #1901