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

hprof: calls to malloc passing a size of 0; causes false 'out of memory' excepti

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • hotspot
    • None
    • generic
    • generic



      Name: tb29552 Date: 10/01/2001


      (Submitted via email to ###@###.###)

      Hi,

      Although the HPROF source code is provided by Sun 'as-is' and is not subject
      to support I thought you might want to know that the code provided from the
      http://java.sun.com/j2se/1.3/docs/guide/jvmpi/jvmpi.html#hprof document at
      the bottom (http://java.sun.com/j2se/1.3/docs/guide/jvmpi/hprof.zip) does
      not run.

      This code blows up with an 'out of memory' exception.

      The problem is at line 149 in the hprof_class.c file

          hstatics = (hprof_field_t *) hprof_calloc(num_statics *
      sizeof(hprof_field_t));


      When the 'num_statics' value is zero the 'hprof_calloc' function calls
      'malloc' with a size of 0 causing malloc to return NULL which causes
      'hprof_calloc' to report an 'out of memory' exception.

      This line of code (and others like it at line 148 and 156) should only be
      called with non-zero values.

      Thanks for providing the code, however. It is very useful in understanding
      how the profiler interface works.


      ======================================================================

            Unassigned Unassigned
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: