Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8221743

ErrorFile option does not handle pre-existing error files of the same name



    • behavioral
    • minimal
    • add/remove/modify command line option
    • JDK



      -XX:ErrorFile="somefile" should replace "somefile" if it exists.


      -XX:ErrorFile="somefile" will, if "somefile" exists, silently default to "./hs_err_pid%p.log".

      This is surprising behavior and can lead to errors and wasted analysis time:

      • If not carefully scanning the output of the crashed processes (If that is even available!) developers may accidentally open the old error file, thinking it new, and work with them.
      • Also, since we silently revert to "./hs_err_pid%p.log", we may now flood the current directory with error reports.

      Note that one can use the "%p" placeholder in the name, which expands to the VM pid and bypasses this problem. But, due to PID reuse, even that may be an old file.


      The file should be replaced, since this is both the most expected behavior as also the behavior causing the least compatibility headaches:


      1) We could just fail to write a file at all, but that would deny us the hs-err file completely.

      2) We could append to the file. But that is somewhat surprising and may lead to the same problem as the current solution, where one mistakes the old content at the start of the file for new output. Also, we may flood the file system.

      3) We could append a suffix to the file name: May be confusing to the user since he expects the original file to find and may not check for the one with the suffix, which would be the correct one. Again, we may flood the file system.

      4) We could rename the old pre-existing file with a suffix: somewhat better than (3) but still could cause flooding the file system.

      Alternative (1) is just not much help. (2)-(4) carry the risk of flooding the file system.


      Patch would be very trivial. Just open the error file without O_EXCL. Currently it is opened with O_CREAT|O_EXCL.


        Issue Links



              stuefe Thomas Stuefe
              stuefe Thomas Stuefe
              Christoph Langer
              0 Vote for this issue
              4 Start watching this issue