From nobody  Thu Oct  8 12:02:38 1998
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.8/8.8.8) id MAA24876;
          Thu, 8 Oct 1998 12:02:38 -0700 (PDT)
          (envelope-from nobody)
Message-Id: <199810081902.MAA24876@hub.freebsd.org>
Date: Thu, 8 Oct 1998 12:02:38 -0700 (PDT)
From: rock@cs.uni-sb.de
To: freebsd-gnats-submit@freebsd.org
Subject: memory leak in rpc.rstatd
X-Send-Pr-Version: www-1.0

>Number:         8212
>Category:       bin
>Synopsis:       memory leak in rpc.rstatd
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ken
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct  8 12:10:01 PDT 1998
>Closed-Date:    Thu Oct 8 12:59:48 PDT 1998
>Last-Modified:  Thu Oct  8 13:01:14 PDT 1998
>Originator:     Daniel Rock
>Release:        latest current (cvsup)
>Organization:
>Environment:
FreeBSD gate 3.0-BETA FreeBSD 3.0-BETA #45: Wed Oct  7 16:42:18 CEST 1998     root@gate:/usr/src/sys/compile/ROCK  i386
>Description:
rpc.rstatd has a memory leak.
Every few invocations from network it requires an additional
page of memory.

>How-To-Repeat:
Comment out rpc.rstatd in /etc/inetd.conf
Start rpc.rstatd manually: /usr/libexec/rpc.rstatd
Type several times "rup localhost"
Watch memory usage with ps or top

>Fix:
diff -c -r1.12 rstat_proc.c
libdevstat allocates memory during each update. This memory has to be
freed.

*** rstat_proc.c        1998/09/16 21:33:14     1.12
--- rstat_proc.c        1998/10/08 19:01:39
***************
*** 365,370 ****
--- 365,372 ----
                }
        }
  
+       if(stats.dinfo->mem_ptr)
+               free(stats.dinfo->mem_ptr);
        free(stats.dinfo);
        return(retval);
  }
***************
*** 424,429 ****
--- 426,433 ----
                }
        }
  
+       if(stats.dinfo->mem_ptr)
+               free(stats.dinfo->mem_ptr);
        free(stats.dinfo);
  }
  

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: ken 
State-Changed-When: Thu Oct 8 12:59:48 PDT 1998 
State-Changed-Why:  
Suggested patch applied with minor modifications in revision 1.13 of 
rstat_proc.c. 


Responsible-Changed-From-To: freebsd-bugs->ken 
Responsible-Changed-By: ken 
Responsible-Changed-When: Thu Oct 8 12:59:48 PDT 1998 
Responsible-Changed-Why:  
I wrote the devstat support for rpc.rstatd. 
>Unformatted:
