On Wed, Feb 12, 2014 at 12:41 PM, Chaitanya Gulhane <
chaitanya.gulh...@gmail.com> wrote:

> Hi Bill,
>
> Thanks for the reply.
>
> Actually I wanted to use Net-SNMP APIs to send traps from my code instead
> of direct calling snmptrap. I saw that my code was having leaks. So I
> curiously tested for snmptrap command for valgrind and its leaking. For me,
> I want to have leak proof code.
>

snmptrap is leaking 35 bytes, in functions that are called only once, in a
process that exits quickly. It is just make-work to try to fix this, IMO.

I looked into stable version available and it was 5.6.2 provided in
> sourceforge.com. I believe that 5.7.2 is pre-release. So I am worried to
> use the same.
>

I'm not sure where you were looking; if I go to
https://sourceforge.net/projects/net-snmp/ the download button points to
5.7.3.pre1.  If you look at http://www.net-snmp.org/ it says "Current
release: 5.7.2" at the top of every page.

  Bill


>
> Regards,
> Chaitanya.
>
>
> On Tue, Feb 11, 2014 at 1:08 AM, Bill Fenner <fen...@gmail.com> wrote:
>
>> On Thu, Feb 6, 2014 at 7:11 AM, Chaitanya Gulhane <
>> chaitanya.gulh...@gmail.com> wrote:
>>
>>>
>>> Hi,
>>>
>>> I was using net-snmp 5.6.2 and have built the code and installed it.
>>>
>>> I was using valgrind over snmptrap command.
>>> Following is the command I ran.
>>>
>>> valgrind --leak-check=full --log-file=log_snmptrap snmptrap -v 2c -c
>>> public "" localhost UCD-TRAP-TEST-MIB::demoTrap
>>>
>>>
>>> Following is the valgrind logging
>>>
>>> ==20969== Memcheck, a memory error detector
>>> ==20969== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
>>> ==20969== Using Valgrind-3.6.0 and LibVEX; rerun with -h for copyright
>>> info
>>> ==20969== Command: snmptrap -v 2c -c public  localhost
>>> UCD-TRAP-TEST-MIB::demoTrap
>>> ==20969== Parent PID: 2080
>>> ==20969==
>>> ==20969== Invalid read of size 8
>>> ==20969==    at 0x35B0E84F66: __GI___strcasecmp_l (in /lib64/
>>> libc-2.12.so)
>>> ==20969==    by 0x4C5F6EB: read_config_find_handler (read_config.c:504)
>>> ==20969==    by 0x4C5F717: run_config_handler (read_config.c:520)
>>> ==20969==    by 0x4C5FE74: read_config (read_config.c:934)
>>> ==20969==    by 0x4C60A98: read_config_files_in_path (read_config.c:1277)
>>> ==20969==    by 0x4C60E7B: read_config_files_of_type (read_config.c:1365)
>>> ==20969==    by 0x4C60ED2: read_config_files (read_config.c:1401)
>>> ==20969==    by 0x4C6146E: read_premib_configs (read_config.c:1045)
>>> ==20969==    by 0x4C43C92: init_snmp (snmp_api.c:848)
>>> ==20969==    by 0x4C58F86: netsnmp_parse_args (snmp_parse_args.c:641)
>>> ==20969==    by 0x4012A1: main (snmptrap.c:147)
>>> ==20969==  Address 0x4f01c18 is 8 bytes inside a block of size 10 alloc'd
>>> ==20969==    at 0x4A05236: malloc (vg_replace_malloc.c:236)
>>> ==20969==    by 0x35B0E81081: strdup (in /lib64/libc-2.12.so)
>>> ==20969==    by 0x4C61D17: internal_register_config_handler
>>> (read_config.c:229)
>>> ==20969==    by 0x4C61B4A: internal_register_config_handler
>>> (read_config.c:185)
>>> ==20969==    by 0x4C73E1B: netsnmp_register_service_handlers
>>> (snmp_service.c:407)
>>> ==20969==    by 0x4C43C6E: init_snmp (snmp_api.c:791)
>>> ==20969==    by 0x4C58F86: netsnmp_parse_args (snmp_parse_args.c:641)
>>> ==20969==    by 0x4012A1: main (snmptrap.c:147)
>>> ==20969==
>>> ==20969== Conditional jump or move depends on uninitialised value(s)
>>> ==20969==    at 0x35B0E84FCB: __GI___strcasecmp_l (in /lib64/
>>> libc-2.12.so)
>>> ==20969==    by 0x4C5F6EB: read_config_find_handler (read_config.c:504)
>>> ==20969==    by 0x4C5F717: run_config_handler (read_config.c:520)
>>> ==20969==    by 0x4C5FE74: read_config (read_config.c:934)
>>> ==20969==    by 0x4C60A98: read_config_files_in_path (read_config.c:1277)
>>> ==20969==    by 0x4C60E7B: read_config_files_of_type (read_config.c:1365)
>>> ==20969==    by 0x4C60ED2: read_config_files (read_config.c:1401)
>>> ==20969==    by 0x4C6146E: read_premib_configs (read_config.c:1045)
>>> ==20969==    by 0x4C43C92: init_snmp (snmp_api.c:848)
>>> ==20969==    by 0x4C58F86: netsnmp_parse_args (snmp_parse_args.c:641)
>>> ==20969==    by 0x4012A1: main (snmptrap.c:147)
>>> ==20969==
>>> ==20969== Use of uninitialised value of size 8
>>> ==20969==    at 0x35B0E87104: __GI___strcasecmp_l (in /lib64/
>>> libc-2.12.so)
>>> ==20969==    by 0x4C5F6EB: read_config_find_handler (read_config.c:504)
>>> ==20969==    by 0x4C5F717: run_config_handler (read_config.c:520)
>>> ==20969==    by 0x4C5FE74: read_config (read_config.c:934)
>>> ==20969==    by 0x4C60A98: read_config_files_in_path (read_config.c:1277)
>>> ==20969==    by 0x4C60E7B: read_config_files_of_type (read_config.c:1365)
>>> ==20969==    by 0x4C60ED2: read_config_files (read_config.c:1401)
>>> ==20969==    by 0x4C6146E: read_premib_configs (read_config.c:1045)
>>> ==20969==    by 0x4C43C92: init_snmp (snmp_api.c:848)
>>> ==20969==    by 0x4C58F86: netsnmp_parse_args (snmp_parse_args.c:641)
>>> ==20969==    by 0x4012A1: main (snmptrap.c:147)
>>> ==20969==
>>> ==20969== Use of uninitialised value of size 8
>>> ==20969==    at 0x35B0E87108: __GI___strcasecmp_l (in /lib64/
>>> libc-2.12.so)
>>> ==20969==    by 0x4C5F6EB: read_config_find_handler (read_config.c:504)
>>> ==20969==    by 0x4C5F717: run_config_handler (read_config.c:520)
>>> ==20969==    by 0x4C5FE74: read_config (read_config.c:934)
>>> ==20969==    by 0x4C60A98: read_config_files_in_path (read_config.c:1277)
>>> ==20969==    by 0x4C60E7B: read_config_files_of_type (read_config.c:1365)
>>> ==20969==    by 0x4C60ED2: read_config_files (read_config.c:1401)
>>> ==20969==    by 0x4C6146E: read_premib_configs (read_config.c:1045)
>>> ==20969==    by 0x4C43C92: init_snmp (snmp_api.c:848)
>>> ==20969==    by 0x4C58F86: netsnmp_parse_args (snmp_parse_args.c:641)
>>> ==20969==    by 0x4012A1: main (snmptrap.c:147)
>>> ==20969==
>>> ==20969== Invalid read of size 8
>>> ==20969==    at 0x35B0E84F5D: __GI___strcasecmp_l (in /lib64/
>>> libc-2.12.so)
>>> ==20969==    by 0x4C7501D: find_tdomain (snmp_transport.c:427)
>>> ==20969==    by 0x4C753AE: netsnmp_tdomain_transport_full
>>> (snmp_transport.c:613)
>>> ==20969==    by 0x401323: main (snmptrap.c:218)
>>> ==20969==  Address 0x4ef8d50 is 0 bytes inside a block of size 4 alloc'd
>>> ==20969==    at 0x4A05236: malloc (vg_replace_malloc.c:236)
>>> ==20969==    by 0x35B0E81081: strdup (in /lib64/libc-2.12.so)
>>> ==20969==    by 0x4C7421A: create_word_array_helper (snmp_service.c:15)
>>> ==20969==    by 0x4C742B9: create_word_array (snmp_service.c:31)
>>> ==20969==    by 0x4C745A9: netsnmp_register_default_domain
>>> (snmp_service.c:87)
>>> ==20969==    by 0x4C43218: _init_snmp (snmp_api.c:694)
>>> ==20969==    by 0x4C433B8: snmp_sess_init (snmp_api.c:730)
>>> ==20969==    by 0x4C581E4: netsnmp_parse_args (snmp_parse_args.c:210)
>>> ==20969==    by 0x4012A1: main (snmptrap.c:147)
>>> ==20969==
>>> ==20969== Invalid read of size 8
>>> ==20969==    at 0x35B0E84F66: __GI___strcasecmp_l (in /lib64/
>>> libc-2.12.so)
>>> ==20969==    by 0x4C7501D: find_tdomain (snmp_transport.c:427)
>>> ==20969==    by 0x4C753AE: netsnmp_tdomain_transport_full
>>> (snmp_transport.c:613)
>>> ==20969==    by 0x401323: main (snmptrap.c:218)
>>> ==20969==  Address 0x4ef8d58 is 4 bytes after a block of size 4 alloc'd
>>> ==20969==    at 0x4A05236: malloc (vg_replace_malloc.c:236)
>>> ==20969==    by 0x35B0E81081: strdup (in /lib64/libc-2.12.so)
>>> ==20969==    by 0x4C7421A: create_word_array_helper (snmp_service.c:15)
>>> ==20969==    by 0x4C742B9: create_word_array (snmp_service.c:31)
>>> ==20969==    by 0x4C745A9: netsnmp_register_default_domain
>>> (snmp_service.c:87)
>>> ==20969==    by 0x4C43218: _init_snmp (snmp_api.c:694)
>>> ==20969==    by 0x4C433B8: snmp_sess_init (snmp_api.c:730)
>>> ==20969==    by 0x4C581E4: netsnmp_parse_args (snmp_parse_args.c:210)
>>> ==20969==    by 0x4012A1: main (snmptrap.c:147)
>>> ==20969==
>>> ==20969==
>>> ==20969== HEAP SUMMARY:
>>> ==20969==     in use at exit: 42 bytes in 3 blocks
>>> ==20969==   total heap usage: 19,431 allocs, 19,428 frees, 1,140,080
>>> bytes allocated
>>> ==20969==
>>> *==20969== 17 bytes in 1 blocks are definitely lost in loss record 2 of
>>> 3*
>>> *==20969==    at 0x4A05236: malloc (vg_replace_malloc.c:236)*
>>> *==20969==    by 0x4C66C51: snmpv3_generate_engineID (snmpv3.c:1563)*
>>> *==20969==    by 0x401652: main (snmptrap.c:175)*
>>> *==20969== *
>>> *==20969== 18 bytes in 1 blocks are definitely lost in loss record 3 of
>>> 3*
>>> *==20969==    at 0x4A05236: malloc (vg_replace_malloc.c:236)*
>>> *==20969==    by 0x40122D: main (snmptrap.c:143)*
>>> ==20969==
>>> ==20969== LEAK SUMMARY:
>>> *==20969==    definitely lost: 35 bytes in 2 blocks*
>>> ==20969==    indirectly lost: 0 bytes in 0 blocks
>>> ==20969==      possibly lost: 0 bytes in 0 blocks
>>> ==20969==    still reachable: 7 bytes in 1 blocks
>>> ==20969==         suppressed: 0 bytes in 0 blocks
>>> ==20969== Reachable blocks (those to which a pointer was found) are not
>>> shown.
>>> ==20969== To see them, rerun with: --leak-check=full --show-reachable=yes
>>> ==20969==
>>> ==20969== For counts of detected and suppressed errors, rerun with: -v
>>> ==20969== Use --track-origins=yes to see where uninitialised values come
>>> from
>>> ==20969== ERROR SUMMARY: 100 errors from 8 contexts (suppressed: 4 from
>>>
>>>
>>> I came to know highlighted memory leaks.
>>>
>>> Is any patch available for the same?
>>>
>>
>> Why do those leaks affect you?  Are you calling main() multiple times in
>> a long-running process in a way that it will allocate these chunks multiple
>> times?  Does your system not release allocated memory when a process exits?
>>
>> (I would be much more worried about the uninitialized value uses than the
>> leaks, myself).
>>
>> Finally, have you tried the most recent release, instead of 5.6.2?
>>
>>   Bill
>>
>>
>
------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to