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

Unable to overwrite files with jmap -dump:file=<path>

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      generic

      Description

      A DESCRIPTION OF THE REQUEST :
      When attempting to overwrite a file that exists, Hotspot yields "File exists" and exits code 0.

      I believe the problem is here:
       http://hg.openjdk.java.net/hsx/hsx25/hotspot/annotate/539144972c1e/src/share/vm/services/heapDumper.cpp#l449

      I am not certain, but it appears if the boolean were changed to true, it would overwrite the specified file.
       _fd = os::create_binary_file(path, false);
      to
       _fd = os::create_binary_file(path, true);

      JUSTIFICATION :
      Centralized virtual machine storage can use smaller attached disks per VM. For memory-intensive Java applications, memory can exceed allocated virtual disk resources. Making heap dumps with jmap and analyzing them off the server is the only way I know how to point to an offending class with excessive memory consumption without adding additional overhead with a profiler. If Hotspot were to write to the specified file regardless of existence, the target file could be a FIFO with an attached process that pipes the memory contents off-server, bypassing writing to disk.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Write the heap dump to the specified file regardless of its existence.
      ACTUAL -
      Prints to stdout:
      Dumping heap to <file path> ...
      File exists

      Exitcode: 0


      ---------- BEGIN SOURCE ----------
      #!/bin/bash

      # Requires a running java process as the user running this script.

      touch /tmp/test.hprof
      jmap -dump:file=/tmp/test.hprof $(pgrep java)

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Potential bypasses include writing to a separate disk, a mount, or enlarging the disk on the virtual machine.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: