Big memory leak in 5.3.1 when traps are sent

Zhouhuai Shen <[email protected]>
Newsgroups gmane.network.net-snmp.user
Message-ID <[email protected]>
Hi All,

When I tried to run an application Cacti to collect network info , such as the memory and cpu usages by the application, I found there is a memory leak in net-snmp. The Cacti is running on a Windows box, which connects to a Linux box running net-snmp 5.3.1. The following is the debug info using Valgrind:

==2214== ERROR SUMMARY: 744 errors from 16 contexts (suppressed: 0 from 0)
==2214== malloc/free: in use at exit: 502,770 bytes in 12,618 blocks.
==2214== malloc/free: 20,963 allocs, 8,345 frees, 29,211,624 bytes allocated.
==2214== For counts of detected errors, rerun with: -v
==2214== searching for pointers to 12,618 not-freed blocks.
==2214== checked 990,336 bytes.
==2214==
==2214==
==2214== 24 bytes in 1 blocks are definitely lost in loss record 29 of 94
==2214==    at 0x402CB70: calloc (in /opt/2/lib/valgrind/ppc32-linux/vgpreload_m
emcheck.so)
==2214==    by 0x4239878: netsnmp_container_get_binary_array (in /lib/libnetsnmp
.so.10.0.1)
==2214==    by 0x4238D98: netsnmp_container_find (in /lib/libnetsnmp.so.10.0.1)
==2214==    by 0x40D82F8: _snmpNotifyFilterTable_initialize_interface (in /lib/l
ibnetsnmpmibs.so.10.0.1)
==2214==    by 0x40B0F9C: initialize_table_snmpNotifyFilterTable (in /lib/libnet
snmpmibs.so.10.0.1)
==2214==    by 0x40B10A0: init_snmpNotifyFilterTable (in /lib/libnetsnmpmibs.so.
10.0.1)
==2214==    by 0x40F58F4: init_mib_modules (in /lib/libnetsnmpmibs.so.10.0.1)
==2214==    by 0x100041DC: (within /sbin/snmpd)
==2214==    by 0x44F3CB8: __uClibc_main (in /lib/libuClibc-0.9.29.so)
==2214==
==2214==
==2214== 40 bytes in 10 blocks are definitely lost in loss record 37 of 94
==2214==    at 0x402DBC0: malloc (in /opt/2/lib/valgrind/ppc32-linux/vgpreload_m
emcheck.so)
==2214==    by 0x419A20C: register_agentx_list (in /lib/libnetsnmpagent.so.10.0.
1)
==2214==    by 0x419AB24: handle_master_agentx_packet (in /lib/libnetsnmpagent.s
o.10.0.1)
==2214==    by 0x420C148: (within /lib/libnetsnmp.so.10.0.1)
==2214==    by 0x420D4FC: _sess_read (in /lib/libnetsnmp.so.10.0.1)
==2214==    by 0x420D800: snmp_sess_read (in /lib/libnetsnmp.so.10.0.1)
==2214==    by 0x420D86C: snmp_read (in /lib/libnetsnmp.so.10.0.1)
==2214==    by 0x10004BE8: (within /sbin/snmpd)
==2214==    by 0x44F3CB8: __uClibc_main (in /lib/libuClibc-0.9.29.so)
==2214==
==2214==
==2214== 12,996 (168 direct, 12,828 indirect) bytes in 7 blocks are definitely l
ost in loss record 80 of 94
==2214==    at 0x402CB70: calloc (in /opt/2/lib/valgrind/ppc32-linux/vgpreload_m
emcheck.so)
==2214==    by 0x41CC188: netsnmp_create_table_data_row (in /lib/libnetsnmphelpe
rs.so.10)
==2214==    by 0x408B384: log_notification (in /lib/libnetsnmpmibs.so.10.0.1)
==2214==    by 0x4088AF0: send_notifications (in /lib/libnetsnmpmibs.so.10.0.1)
==2214==    by 0x4225814: snmp_call_callbacks (in /lib/libnetsnmp.so.10.0.1)
==2214==    by 0x4183754: netsnmp_send_traps (in /lib/libnetsnmpagent.so.10.0.1)
==2214==    by 0x4183794: send_enterprise_trap_vars (in /lib/libnetsnmpagent.so.
10.0.1)
==2214==    by 0x41837F4: send_trap_vars (in /lib/libnetsnmpagent.so.10.0.1)
==2214==    by 0x4199DD4: agentx_notify (in /lib/libnetsnmpagent.so.10.0.1)
==2214==    by 0x419ABA4: handle_master_agentx_packet (in /lib/libnetsnmpagent.s
o.10.0.1)
==2214==    by 0x420C148: (within /lib/libnetsnmp.so.10.0.1)
==2214==    by 0x420D4FC: _sess_read (in /lib/libnetsnmp.so.10.0.1)
==2214==
==2214==
==2214== 172 bytes in 1 blocks are definitely lost in loss record 81 of 94
==2214==    at 0x402CB70: calloc (in /opt/2/lib/valgrind/ppc32-linux/vgpreload_m
emcheck.so)
==2214==    by 0x40E46DC: netsnmp_access_systemstats_entry_update_stats (in /lib
/libnetsnmpmibs.so.10.0.1)
==2214==    by 0x40E49D0: netsnmp_access_systemstats_entry_update (in /lib/libne
tsnmpmibs.so.10.0.1)
==2214==    by 0x40CC934: (within /lib/libnetsnmpmibs.so.10.0.1)
==2214==    by 0x423960C: (within /lib/libnetsnmp.so.10.0.1)
==2214==    by 0x40CC5F8: ipSystemStatsTable_container_load (in /lib/libnetsnmpm
ibs.so.10.0.1)
==2214==    by 0x40CB564: (within /lib/libnetsnmpmibs.so.10.0.1)
==2214==    by 0x41C0F78: (within /lib/libnetsnmphelpers.so.10)
==2214==    by 0x42276D8: run_alarms (in /lib/libnetsnmp.so.10.0.1)
==2214==    by 0x10004CD0: (within /sbin/snmpd)
==2214==    by 0x44F3CB8: __uClibc_main (in /lib/libuClibc-0.9.29.so)

==2217== 4,171,676 (54,144 direct, 4,117,532 indirect) bytes in 2,256 blocks are definitely lost in loss record 92 of 96
==2217==    at 0x402CB70: calloc (in /opt/2/lib/valgrind/ppc32-linux/vgpreload_m
emcheck.so)
==2217==    by 0x41CC188: netsnmp_create_table_data_row (in /lib/libnetsnmphelpe
rs.so.10)
==2217==    by 0x408B384: log_notification (in /lib/libnetsnmpmibs.so.10.0.1)
==2217==    by 0x4088AF0: send_notifications (in /lib/libnetsnmpmibs.so.10.0.1)
==2217==    by 0x4225814: snmp_call_callbacks (in /lib/libnetsnmp.so.10.0.1)
==2217==    by 0x4183754: netsnmp_send_traps (in /lib/libnetsnmpagent.so.10.0.1)
==2217==    by 0x4183794: send_enterprise_trap_vars (in /lib/libnetsnmpagent.so.
10.0.1)
==2217==    by 0x41837F4: send_trap_vars (in /lib/libnetsnmpagent.so.10.0.1)
==2217==    by 0x4199DD4: agentx_notify (in /lib/libnetsnmpagent.so.10.0.1)
==2217==    by 0x419ABA4: handle_master_agentx_packet (in /lib/libnetsnmpagent.s
o.10.0.1)
==2217==    by 0x420C148: (within /lib/libnetsnmp.so.10.0.1)
==2217==    by 0x420D4FC: _sess_read (in /lib/libnetsnmp.so.10.0.1)

By looking at the function that causes the most of memory leak, it looks like when the function netsnmp_create_table_data_row() calloc memories, it fails to deallocate when a trap is sent out but for some reason, the trap packet failed to reach the host.

Is this memory leak a known issue? Has it been fixed in the latest release?

Cheers, Henry

_________________________________________________________________
Get inspired - dream, research, plan and book your next holiday online with MSN NZ Travel 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Ftravel%2Emsn%2Eco%2Enz&_t=771497011&_r=MSN_NZ_travel_hmtagline&_m=EXT

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.