title: Garbage Collector First and JMap EOF bug
body: <p>We are working over our client's production server heap to detect and solve memory leaks. For this we are using jmap periodically to collect the necessary information.</p>
  
  <p>But last week we couldn't take the dump, because it triggered a EOF error and shutdown the Tomcat instance. </p>
  
  <p>I searched on the internet but couldn't find any concrete information about this error. We detected that it only occurs when using the <code>Gc First</code> garbage collector algorithm. </p>
  
  <p>This is the command line we used to perform the jmap:</p>
  
  <p><code>jmap -dump:format=b,file=heap.bin &lt;PID&gt;</code></p>
  
  <p>Java version on the server: JDK 1.7.0_7 x64</p>
  
  <p>Has anyone already faced this kind of error? Maybe some configuration that is missing or a patch to java/jmap required.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>A few more information that we have collected about this error:</p>
  
  <pre><code>[root]# jmap -dump:format=b,file=heap.bin 7806
      Dumping heap to /tmp/heap.bin ...
      Exception in thread "main" java.io.IOException: Premature EOF
          at sun.tools.attach.HotSpotVirtualMachine.readInt(HotSpotVirtualMachine.java:244)
          at sun.tools.attach.LinuxVirtualMachine.execute(LinuxVirtualMachine.java:193)
          at sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualMachine.java:213)
          at sun.tools.attach.HotSpotVirtualMachine.dumpHeap(HotSpotVirtualMachine.java:180)
          at sun.tools.jmap.JMap.dump(JMap.java:241)
          at sun.tools.jmap.JMap.main(JMap.java:140)
  [root]#
  </code></pre>
  
  <p><strong>Note</strong>: the target directory has over 500gb of free space</p>
  
  <p>Error outputed to the catalina.out (JVM dump error):</p>
  
  <pre><code># A fatal error has been detected by the Java Runtime Environment:
  #
  #  SIGSEGV (0xb) at pc=0x00007f0269cc41c6, pid=7806, tid=139647231129360
  #
  # JRE version: Java(TM) SE Runtime Environment (7.0_40-b43) (build 1.7.0_40-b43)
  # Java VM: Java HotSpot(TM) 64-Bit Server VM (24.0-b56 mixed mode linux-amd64 compressed oops)
  # Problematic frame:
  # V  [libjvm.so+0x58c1c6]  DumperSupport::dump_field_value(DumpWriter*, char, unsigned char*)+0x1c6
  #
  # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
  #
  # An error report file with more information is saved as:
  # /opt/tomcat6/bin/hs_err_pid7806.log
  #
  # If you would like to submit a bug report, please visit:
  #   http://bugreport.sun.com/bugreport/crash.jsp
  </code></pre>