RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 678314 - snmptrapd leaks memory when NetSNMP::TrapReceiver is used for trap handlers
Summary: snmptrapd leaks memory when NetSNMP::TrapReceiver is used for trap handlers
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: net-snmp
Version: 6.0
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Jan Safranek
QA Contact: BaseOS QE Security Team
URL:
Whiteboard:
Depends On: 676955
Blocks: 1086761
TreeView+ depends on / blocked
 
Reported: 2011-02-17 14:54 UTC by Jan Safranek
Modified: 2014-04-11 12:24 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
The previous version of snmptrapd, the Net-SNMP daemon for processing traps, leaked memory when processing incoming SNMP traps in embedded Perl. This caused the amount of consumed memory to grow over time, making the memory consumption was even larger if the daemon was processing SNMPv1 traps. With this update, the underlying source code has been adapted to prevent such memory leaks, and processing incoming SNMP traps in embedded Perl no longer increases the memory consumption. (BZ#678314).
Clone Of: 676955
: 1086761 (view as bug list)
Environment:
Last Closed: 2011-12-06 17:11:33 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1524 0 normal SHIPPED_LIVE net-snmp bug fix update 2011-12-06 01:02:35 UTC

Description Jan Safranek 2011-02-17 14:54:16 UTC
+++ This bug was initially created as a clone of Bug #676955 +++

Description of problem:
The NetSNMP::TrapReceiver Perl module distributed in the net-snmp-perl package leaks memory when it is used to register an SNMP trap handler with the snmptrapd process.

Version-Release number of selected component (if applicable):
net-snmp-perl 5.3.2.2-9.el5_5.1
NetSNMP::TrapReceiver 5.03022

How reproducible:
Every time.

Steps to Reproduce:
1. Create a no-op Perl trap handler with this code:

#!/usr/bin/perl
use SNMP;
sub my_receiver {}
NetSNMP::TrapReceiver::register("all", \&my_receiver)
    or warn "Failed to register Perl trap handler\n";
print "Registered Perl trap handler\n";

2. Configure snmptrapd using this line in /etc/snmp/snmptrapd.conf:

perl do "/path/to/subagent";

3. Run snmptrapd with valgrind's memcheck tool:

valgrind -v --leak-check=yes /usr/sbin/snmptrapd -Lsd -p /var/run/snmptrapd.pid -f

4. When the "Registered Perl trap handler" message appears, send one or more traps to the server.

5. Quit valgrind and snmptrapd with ctrl-c. This will display the memcheck report.
  
Actual results:
snmptrapd leaks memory. This is amplified the more traps are sent to the receiver. Eventually, on a busy server, snmptrapd consumes all available memory on the system.

Expected results:
snmptrapd runs memcheck-clean (does not leak memory). Remove the "perl do" line from /etc/snmp/snmptrapd.conf and run the valgrind command in step 3 again and the result will be memcheck-clean.

Comment 1 Jan Safranek 2011-02-17 14:55:01 UTC
The leak appears only when processing V1 traps and it has been fixed upstream:
http://net-snmp.svn.sourceforge.net/viewvc/net-snmp?view=revision&revision=19335

Comment 4 Jan Safranek 2011-08-11 11:32:14 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
The previous version of snmptrapd, the Net-SNMP daemon for processing traps, leaked memory when processing incoming SNMP traps in embedded Perl. This caused the amount of consumed memory to grow over time, making the memory consumption was even larger if the daemon was processing SNMPv1 traps. With this update, the underlying source code has been adapted to prevent such memory leaks, and processing incoming SNMP traps in embedded Perl no longer increases the memory consumption. (BZ#678314).

Comment 7 errata-xmlrpc 2011-12-06 17:11:33 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2011-1524.html

Comment 8 vineela048 2014-01-23 07:01:33 UTC
Hi,

I have tried with all the versions of net-snmp from net-snmp-5.4 till net-snmp-5.7.2 and I still see the memory leak issue for V1 traps. My CPU usage goes quite high with %MEM keeps getting accumulated. 

Below are the statistics -

%CPU Usage - 56.0
%MEM - 8.1
VIRT - 811m
RES - 637m
SHR - 2124

Can you please confirm if this issue has been truly fixed? If so, what is the correct resolution?


Thanks,
Vineela

Comment 9 Jan Safranek 2014-03-06 13:19:26 UTC
(In reply to vineela048 from comment #8)
> Hi,
> 
> I have tried with all the versions of net-snmp from net-snmp-5.4 till
> net-snmp-5.7.2 and I still see the memory leak issue for V1 traps. My CPU
> usage goes quite high with %MEM keeps getting accumulated. 
> 
> Below are the statistics -
> 
> %CPU Usage - 56.0
> %MEM - 8.1
> VIRT - 811m
> RES - 637m
> SHR - 2124
> 
> Can you please confirm if this issue has been truly fixed? If so, what is


The issue described in this bug has been truly fixed, tested today with net-snmp-5.5-49.el6.x86_64. Maybe you experience some other leak or bug. Please keep in mind that bugzilla is not a support tool or means of accessing support. If you would like technical support please visit our support portal at access.redhat.com or


Note You need to log in before you can comment on or make changes to this bug.