-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
JDK-8155004: CrashOnOutOfMemoryError doesn't work for OOM caused by inability to create threads #3586
Conversation
👋 Welcome back stuefe! A progress list of the required criteria for merging this PR into |
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.
Hi Thomas,
As I wrote in the bug report my take on these flags are that they are only intended for a Java heap OOME not arbitrary resource exhaustion where the VM chooses to throw OOME. I have previously rejected a number of "bug" reports about this.
I was wondering if AbortVMOnException would not suffice here for you support case?
Thanks,
David
I would fix it because its a well known and documented way to handle OOMs in a VM. In fact its much better known than AbortVMOnException, and has been around for much longer. People use these switches, expect them to work, but they don't. Other reasons include:
Thanks, Thomas |
p.s. I do not understand your quotes around "bug", nor your hesitance to fix this. I have seen quite a number of desperate setups customers have around crashy or OOMy JVMs, to analyse and to restart quickly. Anything in that area we can do helps. One example, take a look at the way CloudFoundry handles OOMs in a JVM. They have a JVMTI agent hooked up to resource-exhausted, then attempt to run analysis code (written in Java too) to dump the heap. This is so fragile. xxxOnOutOfMemoryError could really help in these scenarios, if it would function reliably. |
Mostly agree with @tstuefe . I give +1 to this PR. I also have seen OOMs due to native thread creation, then I advised to watch the log to reboot the system quickly. However I want to know why JVM ignores it now. Because JVM cannot work correctly if the error is caused by ENOMEM? |
Its simply not implemented. The ...OnOutOfMemoryError handling needs to be added to places where OOM is thrown, and is missing from a couple of places. |
Strictly speaking, we need to think about OOME from Java layer as well. For example, OOME would be thrown when direct buffer cannot allocate native memory (-XX:MaxDirectMemorySize). It is not caught by JVMTI ResourceExhausted event, however it might be important information to know system memory usage. I've found out similar issue on JFR, and I've posted #1403 , however it might not be accepted because C2 might eliminate throwing exceptions. IMHO *OnOutOfMemoryError, unified logging (-Xlog:exceptions), JVMTI event, JFR events should be hook all of OOMEs, they should be able to hook same source at least. |
Please open a new issue for that, we can then discuss this separately.
Fully agree. In fact, I think semantically binding the switches to OutOfMemoryError is a design flaw, since you can have any number of resource bottlenecks where one might wish to restart the VM but which do not result in a OOM in java; one example is the creation of native threads by the VM. But that is a discussion for another day. We seem to have two opposite factions in this discussion. The "works as designed and leave it be" faction and the one wanting to cover as much resource exhaustion cases as possible by these switches. How do we proceed? |
Mailing list message from David Holmes on hotspot-dev: Hi Thomas, On 21/04/2021 12:53 am, Thomas Stuefe wrote:
My hesitance is because the intent of these flags is to provide a I wouldn't object to a general broadening of what this flag applies to And per your latest email perhaps we need new generic flags for Cheers,
|
1 similar comment
Mailing list message from David Holmes on hotspot-dev: Hi Thomas, On 21/04/2021 12:53 am, Thomas Stuefe wrote:
My hesitance is because the intent of these flags is to provide a I wouldn't object to a general broadening of what this flag applies to And per your latest email perhaps we need new generic flags for Cheers,
|
Hi David, (snip)
Okay, I understand your concern now better. If you do not object in principle to broadening of ..OnOutOfMemoryError to cover more cases, but just to the fact that this RFE only handles this one case of resource exhaustion, I think we have common ground. Both Yasumasa and me are fully in favour of making the ..OnOutOfMemoryError coverage as complete as possible. I would prefer to do this one RFE at a time, since that way we can put in work when we have free cycles, and these smaller patches are more easy to backport. Today ..OnOutOfMemoryError is invoked on OOM for both heap- and metaspace exhaustion, and AFAICS has been this way since at least jdk 11. So it is not consistently applied to java heap ooms only.
I'd like that very much. But let me make an argument for fixing the ..OnOutOfMemoryError first, where fixing means making them apply to as many cases of thrown OOMs as possible: The public does not know when these hooks fire and reasonably assume they fire for all instances of OOM, regardless the cause. To my knowledge we never told them differently. Since it is difficult enough to educate them about new options - look at AbortVMOnException, not many seem to know that one - I'd go with the flow and let the switches do what the public always thought they would do. There are a lot of StackOverFlow articles describing these switches, for instance. Cheers, Thomas
|
I like latter, but we need to discuss more because, for example, as you know, description of HeapDumpOnOutOfMemoryError says it affects when an allocation from the Java heap or the permanent generation cannot be satisfied. We will change this spec. I cannot understand "a discussion for another day" well, but... |
Mailing list message from David Holmes on hotspot-dev: Hi Thomas, On 21/04/2021 5:48 pm, Thomas Stuefe wrote:
I've done some more research and I'm less convinced that this is worth
Okay you got me, but these are both allocation regions directly related
An initial google search did not reveal to me any huge issues with these I think if you want to offer similar options for other circumstances, Sorry. Cheers, |
@tstuefe This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 33 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Hello , the description of the flags in globals.hpp says : ExitOnOutOfMemoryError CrashOnOutOfMemoryError So I think the patch Thomas did is fine, it improves the situation where customers expect an exit/crash, when the flag is set accordingly. But they do not get it at the moment. |
Hi David, okay, I'll withdraw the patch and close the issue as wont-fix. We'll keep the fixes downstream. Wrt new flags, this sounds good. JDK 17 would be a good release for such a new flag, but I am not sure yet if I can find the spare cycles. Cheers, Thomas |
Until the JVM has an option to handle this, you can use the simple jvmkill JVMTI agent which does a |
Greetings,
this is an old issue and I'd like to fix it. If we fail to create a java thread due to platform limitations we throw an OOM. But we fail to honor the various xxxOnOutOfMemoryError switches.
The fix is very straightforward.
If fixes
the latter only in theory because most of the times whatever prevented the thread to start up will also prevent the fork needed to get the user command running.
One remaining question, maybe for a future RFE, is how we want to handle native threads creation error. AFAICS currently, failing to create a native thread may or may not result in a fatal shutdown, a log output, or just be ignored, depending on the thread.
If
...OnOutOfMemoryError
is specified, should native thread creation failure be handled the same way as a java thread?Thanks, Thomas
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3586/head:pull/3586
$ git checkout pull/3586
Update a local copy of the PR:
$ git checkout pull/3586
$ git pull https://git.openjdk.java.net/jdk pull/3586/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 3586
View PR using the GUI difftool:
$ git pr show -t 3586
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3586.diff