From nobody@FreeBSD.org  Thu Oct 20 18:27:05 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0E1EB106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 20 Oct 2011 18:27:05 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id E6F538FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 20 Oct 2011 18:27:04 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p9KIR4mv074614
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 20 Oct 2011 18:27:04 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p9KIR4iR074611;
	Thu, 20 Oct 2011 18:27:04 GMT
	(envelope-from nobody)
Message-Id: <201110201827.p9KIR4iR074611@red.freebsd.org>
Date: Thu, 20 Oct 2011 18:27:04 GMT
From: "Eugene M. Zheganin" <eugene@zhegan.in>
To: freebsd-gnats-submit@FreeBSD.org
Subject: net-mgmt/net-snmp memory leak
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         161842
>Category:       ports
>Synopsis:       net-mgmt/net-snmp memory leak
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    zi
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 20 18:30:12 UTC 2011
>Closed-Date:    Tue Nov 15 17:16:42 UTC 2011
>Last-Modified:  Tue Nov 15 17:16:42 UTC 2011
>Originator:     Eugene M. Zheganin
>Release:        FreeBSD 8.2-RELEASE
>Organization:
Norma LLC.
>Environment:
FreeBSD elf.hq.norma.perm.ru 8.2-RELEASE FreeBSD 8.2-RELEASE #1: Thu May  5 19:14:23 YEKST 2011     emz@ns.hq.norma.perm.ru:/usr/obj/usr/src/sys/ELF  i386
>Description:
SNMP Version:

# snmpd -v

NET-SNMP version: 5.7
Web: http://www.net-snmp.org/
Email: net-snmp-coders@lists.sourceforge.net

FreeBSD:
# uname -a
FreeBSD ural85-gw0-alpha 8.2-PRERELEASE FreeBSD 8.2-PRERELEASE #0: Sun Feb 6 12:34:52 YEKT 2011 emz@ural85-gw0-alpha:/usr/obj/usr/src/sys/CRYSTAL amd64


After upgrading from 5.5 to 5.7 got a memory leak.
It is stable and reproduceable. The output below shows it:

# /usr/local/etc/rc.d/snmpd restart
Stopping snmpd.
Waiting for PIDS: 73341.
Starting snmpd.

# ps alx | grep -v egrep | egrep 'RSS|snmp'
UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND
0 73748 1 0 44 0 22860 7144 select S ?? 0:00,21 /usr/local/sbin/snmpd -p /var/run/snmpd.pid -Ls d
# snmpwalk localhost dskTable
(6 times, output skipped)
# ps alx | grep -v egrep | egrep 'RSS|snmp'
UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND
0 73748 1 0 44 0 26956 10756 select S ?? 0:00,50 /usr/local/sbin/snmpd -p /var/run/snmpd.pid -Ls d
# snmpwalk localhost dskTable
(6 times, output skipped)
# ps alx | grep -v egrep | egrep 'RSS|snmp'
UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND
0 73748 1 0 44 0 29004 14232 select S ?? 0:00,62 /usr/local/sbin/snmpd -p /var/run/snmpd.pid -Ls d
# snmpwalk localhost dskTable
(6 times, output skipped)
# ps alx | grep -v egrep | egrep 'RSS|snmp'
UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND
0 73748 1 0 44 0 33100 17804 select S ?? 0:00,80 /usr/local/sbin/snmpd -p /var/run/snmpd.pid -Ls d
# snmpwalk localhost dskTable
(6 times, output skipped)
# ps alx | grep -v egrep | egrep 'RSS|snmp'
UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND
0 73748 1 0 44 0 37196 21352 select S ?? 0:00,95 /usr/local/sbin/snmpd -p /var/run/snmpd.pid -Ls d
# snmpwalk localhost dskTable
(6 times, output skipped)
# ps alx | grep -v egrep | egrep 'RSS|snmp'
UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND
0 73748 1 0 44 0 41292 24908 select S ?? 0:01,09 /usr/local/sbin/snmpd -p /var/run/snmpd.pid -Ls d
# snmpwalk localhost dskTable
(6 times, output skipped)
# ps alx | grep -v egrep | egrep 'RSS|snmp'
UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND
0 73748 1 0 44 0 43340 28440 select S ?? 0:01,25 /usr/local/sbin/snmpd -p /var/run/snmpd.pid -Ls d
# snmpwalk localhost dskTable
(6 times, output skipped)
# ps alx | grep -v egrep | egrep 'RSS|snmp'
UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND
0 73748 1 0 44 0 47436 31936 select S ?? 0:01,39 /usr/local/sbin/snmpd -p /var/run/snmpd.pid -Ls d
(quite some time after doing snmpwalks)
# ps alx | grep -v egrep | egrep 'RSS|snmp'
UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND
0 73748 1 0 45 0 90444 75092 select S ?? 0:02,06 /usr/local/sbin/snmpd -p /var/run/snmpd.pid -Ls d

This can last forever, until the server memory is exausted.
>How-To-Repeat:
Get FreeBSD, install net-snmp port.
>Fix:
Fallback to 5.5.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->sylvio 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Thu Oct 20 18:30:22 UTC 2011 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=161842 

From: "Eugene M. Zheganin" <eugene@zhegan.in>
To: bug-followup@FreeBSD.org, eugene@zhegan.in
Cc:  
Subject: Re: ports/161842: net-mgmt/net-snmp memory leak
Date: Fri, 21 Oct 2011 00:50:48 +0600

 I don't have that on Solaris with 5.7.x; in the SF bug tracker only ppl 
 with FreeBSD confirm this issue, so this is the reason I resubmitted it 
 here.

From: "Eugene M. Zheganin" <eugene@zhegan.in>
To: bug-followup@FreeBSD.org, eugene@zhegan.in
Cc:  
Subject: Re: ports/161842: net-mgmt/net-snmp memory leak
Date: Fri, 21 Oct 2011 10:18:20 +0600

 this patch fixes the issue.
 
 --- agent/mibgroup/hardware/fsys/fsys_getfsstats.c.orig
 +++ agent/mibgroup/hardware/fsys/fsys_getfsstats.c
 @@ -175,4 +175,6 @@ netsnmp_fsys_arch_load( void )
           }
           netsnmp_fsys_calculate32(entry);
       }
 +
 +    free(stats);
   }
Responsible-Changed-From-To: sylvio->zi 
Responsible-Changed-By: zi 
Responsible-Changed-When: Tue Nov 15 17:01:13 UTC 2011 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=161842 
State-Changed-From-To: open->closed 
State-Changed-By: zi 
State-Changed-When: Tue Nov 15 17:16:40 UTC 2011 
State-Changed-Why:  
This was addressed in ports/161064 and the changes exist in 
net-snmp-5.7_4. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=161842 
>Unformatted:
