I am writing an asynchronous polling application and testing it for memory leaks with valgrind. I got valgrind errors regarding system call parameters pointing to uninitiailzed data on the stack (but the program runs as expected).
Then I ran the simple asynchronous application tutorial code ( http://www.net-snmp.org/wiki/index.php/TUT:Simple_Async_Application ) with valgrind and found the same issues (but the program runs as expected). I modified all hosts[i].name to "localhost" in the code so I could query my local host's configured snmpd. I attached the valgrind output with meaningful backtraces (see the error summary section). Could you please explain this issue and what I should do to correct it? I would also like to enable more debugging; what debugging symbols would you recommend? How would you recommend defining _DBG_IF_ and ensuring NETSNMP_NO_DEBUGGING is undefined? Thank you for your time. Brendan
==798== Memcheck, a memory error detector ==798== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al. ==798== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info ==798== Command: ./asyncapp ==798== --798-- Valgrind options: --798-- --tool=memcheck --798-- --leak-check=full --798-- -v --798-- --track-origins=yes --798-- Contents of /proc/version: --798-- Linux version 2.6.32-gentoo-r7 (r...@anon) (gcc version 4.3.4 (Gentoo 4.3.4 p1.1, pie-10.1.5) ) #3 SMP Tue May 18 10:19:02 EDT 2010 --798-- Arch and hwcaps: AMD64, amd64-sse3-cx16 --798-- Page sizes: currently 4096, max supported 4096 --798-- Valgrind library directory: /usr/lib64/valgrind --798-- Reading syms from /home/btauras/snmp_poller/examples/snmp-async-sample/asyncapp (0x400000) --798-- Reading syms from /lib64/ld-2.10.1.so (0x4000000) --798-- Reading debug info from /usr/lib/debug/lib64/ld-2.10.1.so.debug .. --798-- Reading syms from /usr/lib64/valgrind/memcheck-amd64-linux (0x38000000) --798-- Reading debug info from /usr/lib/debug/usr/lib64/valgrind/memcheck-amd64-linux.debug .. --798-- object doesn't have a dynamic symbol table --798-- Reading suppressions file: /usr/lib64/valgrind/default.supp --798-- REDIR: 0x4015c70 (strlen) redirected to 0x3803be43 (vgPlain_amd64_linux_REDIR_FOR_strlen) --798-- Reading syms from /usr/lib64/valgrind/vgpreload_core-amd64-linux.so (0x4a1e000) --798-- Reading debug info from /usr/lib/debug/usr/lib64/valgrind/vgpreload_core-amd64-linux.so.debug .. --798-- Reading syms from /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so (0x4c20000) --798-- Reading debug info from /usr/lib/debug/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so.debug .. ==798== WARNING: new redirection conflicts with existing -- ignoring it --798-- new: 0x04015c70 (strlen ) R-> 0x04c254ac strlen --798-- REDIR: 0x4015ae0 (index) redirected to 0x4c2524b (index) --798-- REDIR: 0x4015b60 (strcmp) redirected to 0x4c25729 (strcmp) --798-- Reading syms from /usr/lib64/libnetsnmp.so.15.1.2 (0x4e29000) --798-- Reading debug info from /usr/lib/debug/usr/lib64/libnetsnmp.so.15.1.2.debug .. --798-- Reading syms from /lib64/libc-2.10.1.so (0x50f1000) --798-- Reading debug info from /usr/lib/debug/lib64/libc-2.10.1.so.debug .. --798-- Reading syms from /usr/lib64/libcrypto.so.0.9.8 (0x544a000) --798-- Reading debug info from /usr/lib/debug/usr/lib64/libcrypto.so.0.9.8.debug .. --798-- Reading syms from /lib64/libdl-2.10.1.so (0x57c5000) --798-- Reading debug info from /usr/lib/debug/lib64/libdl-2.10.1.so.debug .. --798-- Reading syms from /lib64/libz.so.1.2.3 (0x59c9000) --798-- Reading debug info from /usr/lib/debug/lib64/libz.so.1.2.3.debug .. --798-- REDIR: 0x516d3f0 (rindex) redirected to 0x4c25140 (rindex) --798-- REDIR: 0x516d050 (strlen) redirected to 0x4c25475 (strlen) --798-- REDIR: 0x516d250 (strncmp) redirected to 0x4c2568d (strncmp) --798-- REDIR: 0x51692c0 (malloc) redirected to 0x4c23e18 (malloc) --798-- REDIR: 0x5170060 (memcpy) redirected to 0x4c257df (memcpy) --798-- REDIR: 0x516ebf0 (memset) redirected to 0x4c2618a (memset) --798-- REDIR: 0x51688a0 (calloc) redirected to 0x4c22942 (calloc) --798-- REDIR: 0xffffffffff600000 (???) redirected to 0x3803be2f (vgPlain_amd64_linux_REDIR_FOR_vgettimeofday) --798-- REDIR: 0x51691e0 (free) redirected to 0x4c23790 (free) --798-- REDIR: 0x516cac0 (strcmp) redirected to 0x4c256e5 (strcmp) --798-- REDIR: 0x516ca40 (index) redirected to 0x4c251ab (index) --798-- REDIR: 0x516d320 (strncpy) redirected to 0x4c25590 (strncpy) --798-- REDIR: 0x51729c0 (strchrnul) redirected to 0x4c26241 (strchrnul) --798-- REDIR: 0xffffffffff600400 (???) redirected to 0x3803be39 (vgPlain_amd64_linux_REDIR_FOR_vtime) --798-- REDIR: 0x516e4b0 (memchr) redirected to 0x4c257b1 (memchr) --798-- REDIR: 0x516ea40 (memmove) redirected to 0x4c261e9 (memmove) --798-- REDIR: 0x516f720 (mempcpy) redirected to 0x4c26281 (mempcpy) --798-- REDIR: 0x51d4690 (__strcpy_chk) redirected to 0x4c26855 (__strcpy_chk) --798-- REDIR: 0x5172960 (rawmemchr) redirected to 0x4c26269 (rawmemchr) --798-- REDIR: 0x516cb00 (strcpy) redirected to 0x4c254c7 (strcpy) --798-- REDIR: 0x516fd30 (stpcpy) redirected to 0x4c25f22 (stpcpy) --798-- Reading syms from /lib64/libnss_files-2.10.1.so (0x5fde000) --798-- Reading debug info from /usr/lib/debug/lib64/libnss_files-2.10.1.so.debug .. ==798== Syscall param socketcall.sendmsg(msg.msg_control) points to uninitialised byte(s) ==798== at 0x51C2A60: __sendmsg_nocancel (in /lib64/libc-2.10.1.so) ==798== by 0x4E8BB0F: netsnmp_udp_send (snmpUDPDomain.c:184) ==798== by 0x4E60AB2: snmp_sess_async_send (snmp_api.c:4862) ==798== by 0x4E427D2: snmp_synch_response_cb (snmp_client.c:999) ==798== by 0x401414: synchronous (asyncapp.c:153) ==798== by 0x4014D5: main (asyncapp.c:273) ==798== Address 0x7fefff6d8 is on thread 1's stack ==798== Uninitialised value was created by a stack allocation ==798== at 0x4E8B9A2: netsnmp_udp_send (snmpUDPDomain.c:246) ==798== ==798== Syscall param socketcall.sendmsg(msg.msg_control) points to uninitialised byte(s) ==798== at 0x51C2A60: __sendmsg_nocancel (in /lib64/libc-2.10.1.so) ==798== by 0x4E8BB0F: netsnmp_udp_send (snmpUDPDomain.c:184) ==798== by 0x4E60AB2: snmp_sess_async_send (snmp_api.c:4862) ==798== by 0x400F7D: asynchronous (asyncapp.c:231) ==798== by 0x4014E4: main (asyncapp.c:276) ==798== Address 0x7fefff7d8 is on thread 1's stack ==798== Uninitialised value was created by a stack allocation ==798== at 0x4E8B9A2: netsnmp_udp_send (snmpUDPDomain.c:246) ==798== ==798== Syscall param socketcall.sendmsg(msg.msg_control) points to uninitialised byte(s) ==798== at 0x51C2A60: __sendmsg_nocancel (in /lib64/libc-2.10.1.so) ==798== by 0x4E8BB0F: netsnmp_udp_send (snmpUDPDomain.c:184) ==798== by 0x4E60AB2: snmp_sess_async_send (snmp_api.c:4862) ==798== by 0x401315: asynch_response (asyncapp.c:188) ==798== by 0x4E64BB0: _sess_process_packet (snmp_api.c:5239) ==798== by 0x4E669B3: _sess_read (snmp_api.c:5742) ==798== by 0x4E671B0: snmp_sess_read (snmp_api.c:5761) ==798== by 0x4E671F1: snmp_read (snmp_api.c:5378) ==798== by 0x401045: asynchronous (asyncapp.c:254) ==798== by 0x4014E4: main (asyncapp.c:276) ==798== Address 0x7fefff6c8 is on thread 1's stack ==798== Uninitialised value was created by a stack allocation ==798== at 0x4E8B9A2: netsnmp_udp_send (snmpUDPDomain.c:246) ==798== ---------- synchronous ----------- 16:03:52.138134 localhost: SNMPv2-MIB::sysDescr.0 = STRING: Linux anon 2.6.32-gentoo-r7 #3 SMP Tue May 18 10:19:02 EDT 2010 x86_64 16:03:52.219254 localhost: IF-MIB::ifNumber.1 = No Such Instance currently exists at this OID 16:03:52.222581 localhost: IF-MIB::ifNumber.0 = INTEGER: 8 16:03:52.239640 localhost: SNMPv2-MIB::sysDescr.0 = STRING: Linux anon 2.6.32-gentoo-r7 #3 SMP Tue May 18 10:19:02 EDT 2010 x86_64 16:03:52.241337 localhost: IF-MIB::ifNumber.1 = No Such Instance currently exists at this OID 16:03:52.243014 localhost: IF-MIB::ifNumber.0 = INTEGER: 8 16:03:52.245932 localhost: SNMPv2-MIB::sysDescr.0 = STRING: Linux anon 2.6.32-gentoo-r7 #3 SMP Tue May 18 10:19:02 EDT 2010 x86_64 16:03:52.247593 localhost: IF-MIB::ifNumber.1 = No Such Instance currently exists at this OID 16:03:52.249252 localhost: IF-MIB::ifNumber.0 = INTEGER: 8 16:03:52.251938 localhost: SNMPv2-MIB::sysDescr.0 = STRING: Linux anon 2.6.32-gentoo-r7 #3 SMP Tue May 18 10:19:02 EDT 2010 x86_64 16:03:52.253622 localhost: IF-MIB::ifNumber.1 = No Such Instance currently exists at this OID 16:03:52.255289 localhost: IF-MIB::ifNumber.0 = INTEGER: 8 ---------- asynchronous ----------- 16:03:52.269389 localhost: SNMPv2-MIB::sysDescr.0 = STRING: Linux anon 2.6.32-gentoo-r7 #3 SMP Tue May 18 10:19:02 EDT 2010 x86_64 16:03:52.272871 localhost: SNMPv2-MIB::sysDescr.0 = STRING: Linux anon 2.6.32-gentoo-r7 #3 SMP Tue May 18 10:19:02 EDT 2010 x86_64 16:03:52.274832 localhost: SNMPv2-MIB::sysDescr.0 = STRING: Linux anon 2.6.32-gentoo-r7 #3 SMP Tue May 18 10:19:02 EDT 2010 x86_64 16:03:52.276372 localhost: SNMPv2-MIB::sysDescr.0 = STRING: Linux anon 2.6.32-gentoo-r7 #3 SMP Tue May 18 10:19:02 EDT 2010 x86_64 16:03:52.278121 localhost: IF-MIB::ifNumber.1 = No Such Instance currently exists at this OID 16:03:52.279659 localhost: IF-MIB::ifNumber.1 = No Such Instance currently exists at this OID 16:03:52.281188 localhost: IF-MIB::ifNumber.1 = No Such Instance currently exists at this OID 16:03:52.282715 localhost: IF-MIB::ifNumber.1 = No Such Instance currently exists at this OID 16:03:52.284266 localhost: IF-MIB::ifNumber.0 = INTEGER: 8 16:03:52.285761 localhost: IF-MIB::ifNumber.0 = INTEGER: 8 16:03:52.286934 localhost: IF-MIB::ifNumber.0 = INTEGER: 8 16:03:52.288086 localhost: IF-MIB::ifNumber.0 = INTEGER: 8 --798-- Discarding syms at 0x5fe0170-0x5fe75fc in /lib64/libnss_files-2.10.1.so due to munmap() ==798== ==798== HEAP SUMMARY: ==798== in use at exit: 438,561 bytes in 9,021 blocks ==798== total heap usage: 23,085 allocs, 14,064 frees, 2,998,344 bytes allocated ==798== ==798== Searching for pointers to 9,021 not-freed blocks ==798== Checked 849,080 bytes ==798== ==798== 24 bytes in 4 blocks are definitely lost in loss record 328 of 605 ==798== at 0x4C23E8C: malloc (vg_replace_malloc.c:195) ==798== by 0x516CDC1: strdup (strdup.c:43) ==798== by 0x401384: synchronous (asyncapp.c:142) ==798== by 0x4014D5: main (asyncapp.c:273) ==798== ==798== 24 bytes in 4 blocks are definitely lost in loss record 329 of 605 ==798== at 0x4C23E8C: malloc (vg_replace_malloc.c:195) ==798== by 0x516CDC1: strdup (strdup.c:43) ==798== by 0x400EF4: asynchronous (asyncapp.c:220) ==798== by 0x4014E4: main (asyncapp.c:276) ==798== ==798== 40 bytes in 4 blocks are definitely lost in loss record 413 of 605 ==798== at 0x4C23E8C: malloc (vg_replace_malloc.c:195) ==798== by 0x516CDC1: strdup (strdup.c:43) ==798== by 0x401376: synchronous (asyncapp.c:141) ==798== by 0x4014D5: main (asyncapp.c:273) ==798== ==798== 40 bytes in 4 blocks are definitely lost in loss record 414 of 605 ==798== at 0x4C23E8C: malloc (vg_replace_malloc.c:195) ==798== by 0x516CDC1: strdup (strdup.c:43) ==798== by 0x400EE3: asynchronous (asyncapp.c:219) ==798== by 0x4014E4: main (asyncapp.c:276) ==798== ==798== LEAK SUMMARY: ==798== definitely lost: 128 bytes in 16 blocks ==798== indirectly lost: 0 bytes in 0 blocks ==798== possibly lost: 0 bytes in 0 blocks ==798== still reachable: 438,433 bytes in 9,005 blocks ==798== suppressed: 0 bytes in 0 blocks ==798== Reachable blocks (those to which a pointer was found) are not shown. ==798== To see them, rerun with: --leak-check=full --show-reachable=yes ==798== ==798== ERROR SUMMARY: 28 errors from 7 contexts (suppressed: 6 from 6) ==798== ==798== 4 errors in context 1 of 7: ==798== Syscall param فففففففففففففففففففففففففففففففففففففففففففففففف points to uninitialised byte(s) ==798== at 0x51C2A60: __sendmsg_nocancel (in /lib64/libc-2.10.1.so) ==798== by 0x4E8BB0F: netsnmp_udp_send (snmpUDPDomain.c:184) ==798== by 0x4E60AB2: snmp_sess_async_send (snmp_api.c:4862) ==798== by 0x400F7D: asynchronous (asyncapp.c:231) ==798== by 0x4014E4: main (asyncapp.c:276) ==798== Address 0x7fefff7d8 is on thread 1's stack ==798== Uninitialised value was created by a stack allocation ==798== at 0x4E8B9A2: netsnmp_udp_send (snmpUDPDomain.c:246) ==798== ==798== ==798== 8 errors in context 2 of 7: ==798== Syscall param فففففففففففففففففففففففففففففففففففففففففففففففف points to uninitialised byte(s) ==798== at 0x51C2A60: __sendmsg_nocancel (in /lib64/libc-2.10.1.so) ==798== by 0x4E8BB0F: netsnmp_udp_send (snmpUDPDomain.c:184) ==798== by 0x4E60AB2: snmp_sess_async_send (snmp_api.c:4862) ==798== by 0x401315: asynch_response (asyncapp.c:188) ==798== by 0x4E64BB0: _sess_process_packet (snmp_api.c:5239) ==798== by 0x4E669B3: _sess_read (snmp_api.c:5742) ==798== by 0x4E671B0: snmp_sess_read (snmp_api.c:5761) ==798== by 0x4E671F1: snmp_read (snmp_api.c:5378) ==798== by 0x401045: asynchronous (asyncapp.c:254) ==798== by 0x4014E4: main (asyncapp.c:276) ==798== Address 0x7fefff6c8 is on thread 1's stack ==798== Uninitialised value was created by a stack allocation ==798== at 0x4E8B9A2: netsnmp_udp_send (snmpUDPDomain.c:246) ==798== ==798== ==798== 12 errors in context 3 of 7: ==798== Syscall param فففففففففففففففففففففففففففففففففففففففففففففففف points to uninitialised byte(s) ==798== at 0x51C2A60: __sendmsg_nocancel (in /lib64/libc-2.10.1.so) ==798== by 0x4E8BB0F: netsnmp_udp_send (snmpUDPDomain.c:184) ==798== by 0x4E60AB2: snmp_sess_async_send (snmp_api.c:4862) ==798== by 0x4E427D2: snmp_synch_response_cb (snmp_client.c:999) ==798== by 0x401414: synchronous (asyncapp.c:153) ==798== by 0x4014D5: main (asyncapp.c:273) ==798== Address 0x7fefff6d8 is on thread 1's stack ==798== Uninitialised value was created by a stack allocation ==798== at 0x4E8B9A2: netsnmp_udp_send (snmpUDPDomain.c:246) ==798== --798-- --798-- used_suppression: 4 dl-hack3-cond-1 --798-- used_suppression: 2 glibc-2.5.x-on-SUSE-10.2-(PPC)-2a ==798== ==798== ERROR SUMMARY: 28 errors from 7 contexts (suppressed: 6 from 6)
------------------------------------------------------------------------------
_______________________________________________ Net-snmp-coders mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
