JDK-8244617 : If "CreateCoredumpOnCrash" is set, then we should call setrlimit(RLIMIT_CORE)
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • Submitted: 2020-05-07
  • Updated: 2020-05-12
  • Resolved: 2020-05-12
Related Reports
Relates :  
Relates :  
Description
A user may set "CreateCoredumpOnCrash" flag to request core dumps, but they may not be actually created if the user does not set "ulimit -c unlimited"

We can, and should, set the limit programmatically, however, to ensure that core files are indeed written, by calling setrlimit(RLIMIT_CORE)

See https://developer.apple.com/library/archive/technotes/tn2124/_index.html
Comments
RT Triage: the code is working as intended.
12-05-2020

CreateCoreDumpOnCrash might be better named RequestCoreDumpOnCrash (not that I suggest doing that due to the perturbation it would cause). We can change the description: "Request creation of a core-file/mini-dump on VM fatal error. Creation may be prohibited by environmental settings."
11-05-2020

Perhaps it could be made clearer. The default position is that we will try to create a core dump when we crash, but the user's environment can prevent that. The CreateCoreDumpOnCrash flag is a way for the user to explicitly say "I don't want core dumps" regardless of whether their environment would permit core dumps or not. Setting -XX:+CreateCoreDumpsOnCrash does not mean "I want the VM to do everything possible to make sure that I really will get a core dump". If such a feature were desirable (which I don't think it is) then ForceCoreDumpOnCrash would be a better name for it.
11-05-2020

Or maybe you can add the last sentence to the existing option.
11-05-2020

I assumed that CreateCoreDumpOnCrash was false by default. Even though I agree with Coleen argument, I find it very ironic that making sure that "CreateCoreDumpOnCrash" actually does what it says isn't the right choice (unless we flip it to false by default). The comment for "CreateCoreDumpOnCrash" is "Create core/mini dump on VM fatal error", which is not in fact true, unless the user platform is set to allow it (which we could do programmatically). I find the current state of crash core related mechanism vague, confusing and misleading at best.
08-05-2020

Please don't do this! CreateCoreDumpOnCrash is default and I run with limit coredumpsize 0 so that my disk doesn't fill up with core dumps when I'm working on things. I don't want to have to remember for every test/invocation etc to switch it the other way. This is how it works now and changing it could affect more people negatively.
08-05-2020

CreateCoredumpOnCrash is enabled by default (except on Windows client) and exists primarily to allow disabling of core dumps if they would otherwise occur (mainly for testing - and the special cases of a popular game crashing on Windows client). I don't think we should be messing with rlimit ourselves. If anything you could report if core dumps appear disabled if the user explicitly requests -XX:+CreateCoredumpOnCrash on the command-line. But this seems like a solution in search of a problem to me.
08-05-2020