[rabbitmq-discuss] [rabbitmq-c-master] memory leakinkg while reconnect.

Alan Antonuk alan.antonuk at gmail.com
Thu Feb 13 16:07:32 GMT 2014


Rohit;


On Thu, Feb 13, 2014 at 7:05 AM, Rohit Patle
<Rohit.Patle at techmahindra.com>wrote:

>  Hi Alan,
>
> As suggested by you I run our code with Valgrind and also with GDB bellow
> is the outcome for your reference.
>

For your valgrind run could you modify your program to exit the program
after doing a couple runs of your loop (instead of using ^C to break out of
the program)? The leak that valgrind is showing is because the program is
being terminated in the middle of the loop, so the amqp_connection_state_t
object isn't freed.

When I tried to reproduce your situation last night by repeatedly failing
to connect to a broker in a tight loop (you should really consider having
some kind of exponential back-off or a limit on the number of retries in
this case too...) I was unable to reproduce the runaway memory consumption
you were seeing.


> From GDB outcome I can see that the Segmentation fault occurs due to non
> availability of malloc_consolidate in malloc.c also I am not able to find
> the file in my downloaded rabbitmq-c-master package.
>

malloc.c is part of the C standard library, probably glibc. The fact that
gdb cannot find is is not surprising (and not really of too much concern in
this case - gdb is just looking for it to print out the line that thinks
the segfault occurred on). The segfault however is concerning - when you
get these you should do a 'bt' command in gdb which will give you a
backtrace. Its easier to then to figure out what call into malloc() or
free() is causing the error.

-Alan


> Please suggest.
>
> ========================= Valgrind ======================
> ==6778==
> ==6778== Process terminating with default action of signal 2 (SIGINT)
> ==6778==    at 0x414D311: connect (socket.S:64)
> ==6778==    by 0x69682E30: ???
> ==6778==
> ==6778== HEAP SUMMARY:
> ==6778==     in use at exit: 667,319 bytes in 3,295 blocks
> ==6778==   total heap usage: 4,393 allocs, 1,098 frees, 789,240 bytes
> allocated
> ==6778==
> ==6778== Searching for pointers to 3,295 not-freed blocks
> ==6778== Checked 206,660 bytes
> ==6778==
> ==6778== 414,730 (344 direct, 414,386 indirect) bytes in 2 blocks are
> definitely lost in loss record 378 of 378
> ==6778==    at 0x402A5E6: calloc (in
> /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
> ==6778==    by 0x404C623: amqp_new_connection (amqp_connection.c:68)
> ==6778==    by 0x40754D2: (below main) (libc-start.c:226)
> ==6778==
> ==6778== LEAK SUMMARY:
> ==6778==    definitely lost: 344 bytes in 2 blocks
> ==6778==    indirectly lost: 414,386 bytes in 372 blocks
> ==6778==      possibly lost: 0 bytes in 0 blocks
> ==6778==    still reachable: 252,589 bytes in 2,921 blocks
> ==6778==         suppressed: 0 bytes in 0 blocks
> ==6778== Reachable blocks (those to which a pointer was found) are not
> shown.
> ==6778== To see them, rerun with: --leak-check=full --show-reachable=yes
> ==6778==
> ==6778== Use --track-origins=yes to see where uninitialised values come
> from
> ==6778== ERROR SUMMARY: 7 errors from 2 contexts (suppressed: 0 from 0)
> ==6778==
> ==6778== 6 errors in context 1 of 2:
> ==6778== Conditional jump or move depends on uninitialised value(s)
> ==6778==    at 0x4346494: ASN1_STRING_set (asn1_lib.c:382)
> ==6778==    by 0x432FF02: ASN1_mbstring_ncopy (a_mbstr.c:204)
> ==6778==    by 0x433018A: ASN1_mbstring_copy (a_mbstr.c:86)
> ==6778==    by 0x4331258: ASN1_STRING_to_UTF8 (a_strex.c:570)
> ==6778==    by 0x4332F0B: x509_name_canon (x_name.c:408)
> ==6778==    by 0x43335BF: x509_name_ex_d2i (x_name.c:210)
> ==6778==    by 0x433B017: ASN1_item_ex_d2i (tasn_dec.c:239)
> ==6778==    by 0x433BD9E: asn1_template_noexp_d2i (tasn_dec.c:746)
> ==6778==
> ==6778== ERROR SUMMARY: 7 errors from 2 contexts (suppressed: 0 from 0)
> ===============================END==================
>
> GDB outcome:
>
> ========================== GDB =======================
> Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
> creating connection
> opening SSL/TLS connection
>
> Program received signal SIGSEGV, Segmentation fault.
> 0xb7e80175 in malloc_consolidate (av=0xb7fb0440) at malloc.c:4278
> 4278    malloc.c: No such file or directory.
> (gdb) n
> =====================================================
>
> Thanks & Regards,
> Rohit
>
>
>
> ------------------------------
>
> DISCLAIMER:
> This email (including any attachments) is intended for the sole use of the
> intended recipient/s and may contain material that is CONFIDENTIAL AND
> PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or
> distribution or forwarding of any or all of the contents in this message is
> STRICTLY PROHIBITED. If you are not the intended recipient, please contact
> the sender by email and delete all copies; your cooperation in this regard
> is appreciated.
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140213/52e7cb25/attachment.html>


More information about the rabbitmq-discuss mailing list