Menu

#42 Memory leak on OpenSolaris

v3.8beta
open
nobody
5
2009-02-12
2009-02-12
No

It is reported that top 3.8beta1 has a memory leak under OpenSolaris. Heap memory is leaked for each top update. Some users have seen the top process size grow to 1.5GB.

Recent OpenSolaris is providing top 3.8beta1.

Discussion

  • Bob Friesenhahn

    Bob Friesenhahn - 2009-02-12

    More information regarding this bug may be found in the OpenSolaris bug tracker at http://defect.opensolaris.org/bz/show_bug.cgi?id=5482.

     
  • Renaud Manus

    Renaud Manus - 2009-03-12

    In getptable(), we allocate a buffer

    /* read the whole file */
    p = malloc(st.st_size);
    (void)pread(fd, p, st.st_size, 0);

    but then we change the value of p

    /* the file starts with a struct prheader */
    prp = (prheader_t *)p;
    p += sizeof(prheader_t);

    So, it will fail when p is freed.

    The fix is as simple as this:

    --- machine/m_sunos5.c_orig 2009-03-12 10:49:47.109880555 +0000
    +++ machine/m_sunos5.c 2009-03-12 10:49:10.904476809 +0000
    @@ -2148,7 +2148,7 @@ getptable (struct prpsinfo *baseptr)
    op->oldtime = TIMESPEC_TO_DOUBLE(lwpp->pr_time);
    op->seen = 1;
    }
    - free(p);
    + free(prp);
    }
    #endif

     

Log in to post a comment.