Is the crash file path available from the JVM?

Shawn Heisey java at elyograg.org
Wed Oct 12 14:08:16 UTC 2022


I am working on changing the Solr project from using a shell script to 
kill Solr on OOME to crashing the JVM on OOME.

https://issues.apache.org/jira/browse/SOLR-8803

This is part of the code I am currently working on adding:

     long pid = 0L;
     try {
       pid = ProcessHandle.current().pid();
     } catch (Exception e) {
       if (log.isErrorEnabled()) {
         log.error("Error trying to get PID.", e);
       }
     }
     if (log.isWarnEnabled()) {
       String tmpDir = System.getProperty("java.io.tmpdir");
       if (pid == 0L) {
         log.warn("Java tmpdir:");
         log.warn(tmpDir);
       } else {
         StringBuilder sb = new StringBuilder();
         sb.append(tmpDir);
         sb.append(FileSystems.getDefault().getSeparator());
         sb.append("hs_err_pid");
         sb.append(pid);
         sb.append(".log");
         String crashFile = sb.toString();
         log.warn("Java crash file location:");
         log.warn(crashFile);
       }
     }

But what I am hoping is to be able to ask Java for the fully qualified 
crash file path and remove the "manageProcess" permission I had to add 
to the security manager in order to get the PID.  Is the crash file path 
available without adding permissions to the security manager?  I have 
been searching and haven't found anything.

I know this isn't exactly on-topic for this particular mailing list, but 
it is related to OOME, so it sort of fits.  I didn't want to add yet 
another mailing list for a one-off question.

Thanks,
Shawn



More information about the hotspot-gc-use mailing list