Re: valgrind - gw_check_leaks() - memory leaks etc

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: valgrind - gw_check_leaks() - memory leaks etc

fred-30
Stipe
"yep, agree'ing... BTW, debugging memory leaks may be done with valgrind. Which
is our favorite approach to identify these kind of issues.

"
 
Ah so someone else uses valgrind!!
any opinion about what I ask here?
----- Original Message -----
Sent: Wednesday, December 07, 2005 12:17 PM
Subject: valgrind - gw_check_leaks() - memory leaks etc

If someone could take a look at some of these....
Eg invalid read size 4 in lock....ie
 
static void lock(List *list)
{
    gw_assert(list != NULL);
    mutex_lock(list->single_operation_lock);
}
 
what is wrong here? anyone? and why would valgrind report this...kannel seems to be working fine........
 
this valgrind is not too  bad  a tool.. has anyone used it on kannel?
it.has found some memory leaks from some code I added.....
for the Question here I'm more concerned about those invalid reads...to do with the library code....
 
 
I have been trying to use the gwlib memcheck thing too, I've got
-DUSE_GWMEM_CHECK -DUSE_GWMEM_SLOW  defined for compiling but there seems no sign of gw_init_mem(),
 gw_check_leaks();
 
I checked the compile with -E preprocessor output, and they are still not there!!!.......-DUSE_GWMEM_CHECK  is correct ? right ???
what am I missing? I've overlooked something but don't know what.............
 
 
 
==3368== Memcheck, a memory error detector.
==3368== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==3368== Using LibVEX rev 1471, a library for dynamic binary translation.
==3368== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP.
==3368== Using valgrind-3.1.0, a dynamic binary instrumentation framework.
==3368== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==3368== For more details, rerun with: -v
==3368==
==3368== My PID = 3368, parent PID = 3367.  Prog and args are:
==3368==    ./bearerbox
==3368==    /usr/local/5thfinger/conf/kannel-voda7.conf
==3368==
==3368== Thread 2:
==3368== Conditional jump or move depends on uninitialised value(s)
==3368==    at 0x80C9B00: gwthread_poll (gwthread-pthread.c:722)
==3368==    by 0x80C7475: poller (fdset.c:331)
==3368==    by 0x80C903F: new_thread (gwthread-pthread.c:346)
==3368==    by 0x40B6DFB: start_thread (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x438DF29: clone (in /lib/tls/libc-2.3.2.so)
==3368==
==3368== Thread 6:
==3368== Invalid read of size 4
==3368==    at 0x80D2683: lock (list.c:525)
==3368==    by 0x80D2265: gwlist_remove_producer (list.c:398)
==3368==    by 0x8057EDA: smsboxc_run (bb_boxc.c:1196)
==3368==    by 0x80C903F: new_thread (gwthread-pthread.c:346)
==3368==    by 0x40B6DFB: start_thread (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x438DF29: clone (in /lib/tls/libc-2.3.2.so)
==3368==  Address 0x46C5908 is 16 bytes inside a block of size 76 free'd
==3368==    at 0x401B14C: free (vg_replace_malloc.c:235)
==3368==    by 0x80C7EC3: gw_native_free (gwmem-native.c:110)
==3368==    by 0x80D1A10: gwlist_destroy (list.c:158)
==3368==    by 0x8053B4F: main (bearerbox.c:676)
==3368==
==3368== Invalid read of size 4
==3368==    at 0x40B8737: pthread_mutex_lock (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x80DE08F: mutex_lock_real (thread.c:135)
==3368==    by 0x80D268A: lock (list.c:525)
==3368==    by 0x80D2265: gwlist_remove_producer (list.c:398)
==3368==    by 0x8057EDA: smsboxc_run (bb_boxc.c:1196)
==3368==    by 0x80C903F: new_thread (gwthread-pthread.c:346)
==3368==    by 0x40B6DFB: start_thread (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x438DF29: clone (in /lib/tls/libc-2.3.2.so)
==3368==  Address 0x46C5984 is 12 bytes inside a block of size 32 free'd
==3368==    at 0x401B14C: free (vg_replace_malloc.c:235)
==3368==    by 0x80C7EC3: gw_native_free (gwmem-native.c:110)
==3368==    by 0x80DE04F: mutex_destroy (thread.c:117)
==3368==    by 0x80D19E0: gwlist_destroy (list.c:155)
==3368==    by 0x8053B4F: main (bearerbox.c:676)
==3368==
==3368== Invalid read of size 4
==3368==    at 0x40B874B: pthread_mutex_lock (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x80DE08F: mutex_lock_real (thread.c:135)
==3368==    by 0x80D268A: lock (list.c:525)
==3368==    by 0x80D2265: gwlist_remove_producer (list.c:398)
==3368==    by 0x8057EDA: smsboxc_run (bb_boxc.c:1196)
==3368==    by 0x80C903F: new_thread (gwthread-pthread.c:346)
==3368==    by 0x40B6DFB: start_thread (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x438DF29: clone (in /lib/tls/libc-2.3.2.so)
==3368==  Address 0x46C5978 is 0 bytes inside a block of size 32 free'd
==3368==    at 0x401B14C: free (vg_replace_malloc.c:235)
==3368==    by 0x80C7EC3: gw_native_free (gwmem-native.c:110)
==3368==    by 0x80DE04F: mutex_destroy (thread.c:117)
==3368==    by 0x80D19E0: gwlist_destroy (list.c:155)
==3368==    by 0x8053B4F: main (bearerbox.c:676)
==3368==
==3368== Invalid read of size 4
==3368==    at 0x40B8751: pthread_mutex_lock (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x80DE08F: mutex_lock_real (thread.c:135)
==3368==    by 0x80D268A: lock (list.c:525)
==3368==    by 0x80D2265: gwlist_remove_producer (list.c:398)
==3368==    by 0x8057EDA: smsboxc_run (bb_boxc.c:1196)
==3368==    by 0x80C903F: new_thread (gwthread-pthread.c:346)
==3368==    by 0x40B6DFB: start_thread (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x438DF29: clone (in /lib/tls/libc-2.3.2.so)
==3368==  Address 0x46C5988 is 16 bytes inside a block of size 32 free'd
==3368==    at 0x401B14C: free (vg_replace_malloc.c:235)
==3368==    by 0x80C7EC3: gw_native_free (gwmem-native.c:110)
==3368==    by 0x80DE04F: mutex_destroy (thread.c:117)
==3368==    by 0x80D19E0: gwlist_destroy (list.c:155)
==3368==    by 0x8053B4F: main (bearerbox.c:676)
==3368==
==3368== Invalid write of size 4
==3368==    at 0x40B8754: pthread_mutex_lock (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x80DE08F: mutex_lock_real (thread.c:135)
==3368==    by 0x80D268A: lock (list.c:525)
==3368==    by 0x80D2265: gwlist_remove_producer (list.c:398)
==3368==    by 0x8057EDA: smsboxc_run (bb_boxc.c:1196)
==3368==    by 0x80C903F: new_thread (gwthread-pthread.c:346)
==3368==    by 0x40B6DFB: start_thread (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x438DF29: clone (in /lib/tls/libc-2.3.2.so)
==3368==  Address 0x46C5980 is 8 bytes inside a block of size 32 free'd
==3368==    at 0x401B14C: free (vg_replace_malloc.c:235)
==3368==    by 0x80C7EC3: gw_native_free (gwmem-native.c:110)
==3368==    by 0x80DE04F: mutex_destroy (thread.c:117)
==3368==    by 0x80D19E0: gwlist_destroy (list.c:155)
==3368==    by 0x8053B4F: main (bearerbox.c:676)
==3368==
==3368== Invalid read of size 4
==3368==    at 0x80DE0CB: mutex_lock_real (thread.c:140)
==3368==    by 0x80D268A: lock (list.c:525)
==3368==    by 0x80D2265: gwlist_remove_producer (list.c:398)
==3368==    by 0x8057EDA: smsboxc_run (bb_boxc.c:1196)
==3368==    by 0x80C903F: new_thread (gwthread-pthread.c:346)
==3368==    by 0x40B6DFB: start_thread (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x438DF29: clone (in /lib/tls/libc-2.3.2.so)
==3368==  Address 0x46C5990 is 24 bytes inside a block of size 32 free'd
==3368==    at 0x401B14C: free (vg_replace_malloc.c:235)
==3368==    by 0x80C7EC3: gw_native_free (gwmem-native.c:110)
==3368==    by 0x80DE04F: mutex_destroy (thread.c:117)
==3368==    by 0x80D19E0: gwlist_destroy (list.c:155)
==3368==    by 0x8053B4F: main (bearerbox.c:676)
==3368==
==3368== Invalid write of size 4
==3368==    at 0x80DE0FF: mutex_lock_real (thread.c:143)
==3368==    by 0x80D268A: lock (list.c:525)
==3368==    by 0x80D2265: gwlist_remove_producer (list.c:398)
==3368==    by 0x8057EDA: smsboxc_run (bb_boxc.c:1196)
==3368==    by 0x80C903F: new_thread (gwthread-pthread.c:346)
==3368==    by 0x40B6DFB: start_thread (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x438DF29: clone (in /lib/tls/libc-2.3.2.so)
==3368==  Address 0x46C5990 is 24 bytes inside a block of size 32 free'd
==3368==    at 0x401B14C: free (vg_replace_malloc.c:235)
==3368==    by 0x80C7EC3: gw_native_free (gwmem-native.c:110)
==3368==    by 0x80DE04F: mutex_destroy (thread.c:117)
==3368==    by 0x80D19E0: gwlist_destroy (list.c:155)
==3368==    by 0x8053B4F: main (bearerbox.c:676)
==3368==
==3368== Invalid read of size 4
==3368==    at 0x80D226C: gwlist_remove_producer (list.c:399)
==3368==    by 0x8057EDA: smsboxc_run (bb_boxc.c:1196)
==3368==    by 0x80C903F: new_thread (gwthread-pthread.c:346)
==3368==    by 0x40B6DFB: start_thread (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x438DF29: clone (in /lib/tls/libc-2.3.2.so)
==3368==  Address 0x46C5940 is 72 bytes inside a block of size 76 free'd
==3368==    at 0x401B14C: free (vg_replace_malloc.c:235)
==3368==    by 0x80C7EC3: gw_native_free (gwmem-native.c:110)
==3368==    by 0x80D1A10: gwlist_destroy (list.c:158)
==3368==    by 0x8053B4F: main (bearerbox.c:676)
==3368==
==3368== ERROR SUMMARY: 171 errors from 9 contexts (suppressed: 41 from 1)
==3368== malloc/free: in use at exit: 1,460,552 bytes in 24,382 blocks.
==3368== malloc/free: 6,469,819 allocs, 6,445,437 frees, 2,350,245,849 bytes allocated.
==3368== For counts of detected errors, rerun with: -v
==3368== searching for pointers to 24,382 not-freed blocks.
==3368== checked 32,489,364 bytes.
==3368==
==3368== Thread 1:
==3368==
==3368== 16 bytes in 1 blocks are possibly lost in loss record 1 of 15
==3368==    at 0x401A639: malloc (vg_replace_malloc.c:149)
==3368==    by 0x80C7E19: gw_native_malloc (gwmem-native.c:86)
==3368==    by 0x80D48B8: octstr_create_from_data_real (octstr.c:255)
==3368==    by 0x80D4D15: octstr_duplicate_real (octstr.c:366)
==3368==    by 0x806173F: dlr_add (dlr.c:371)
==3368==    by 0x808BC6D: handle_pdu (smsc_smpp.c:1462)
==3368==    by 0x808C7D6: io_thread (smsc_smpp.c:1760)
==3368==    by 0x80C903F: new_thread (gwthread-pthread.c:346)
==3368==    by 0x40B6DFB: start_thread (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x438DF29: clone (in /lib/tls/libc-2.3.2.so)
==3368==
==3368==
==3368== 68 bytes in 1 blocks are definitely lost in loss record 2 of 15
==3368==    at 0x401B911: calloc (vg_replace_malloc.c:279)
==3368==    by 0x400EC2B: _dl_allocate_tls (in /lib/ld-2.3.2.so)
==3368==    by 0x40B727D: allocate_stack (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x40B6F07: [hidden email] (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x80C92A8: spawn_thread (gwthread-pthread.c:446)
==3368==    by 0x80C939E: gwthread_create_real (gwthread-pthread.c:486)
==3368==    by 0x80588EC: smsbox_start (bb_boxc.c:1406)
==3368==    by 0x8052AC9: start_smsc (bearerbox.c:234)
==3368==    by 0x8053452: init_bearerbox (bearerbox.c:492)
==3368==    by 0x8053919: main (bearerbox.c:600)
==3368==
==3368==
==3368== 204 bytes in 3 blocks are possibly lost in loss record 4 of 15
==3368==    at 0x401B911: calloc (vg_replace_malloc.c:279)
==3368==    by 0x400EC2B: _dl_allocate_tls (in /lib/ld-2.3.2.so)
==3368==    by 0x40B727D: allocate_stack (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x40B6F07: [hidden email] (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x80C92A8: spawn_thread (gwthread-pthread.c:446)
==3368==    by 0x80C939E: gwthread_create_real (gwthread-pthread.c:486)
==3368==    by 0x80C7764: fdset_create_real (fdset.c:384)
==3368==    by 0x80CEE32: start_server_thread (http.c:2281)
==3368==    by 0x80CEF74: http_open_port_if (http.c:2310)
==3368==    by 0x805B71D: httpadmin_start (bb_http.c:637)
==3368==    by 0x8053300: init_bearerbox (bearerbox.c:461)
==3368==    by 0x8053919: main (bearerbox.c:600)
==3368==
==3368==
==3368== 270 bytes in 1 blocks are definitely lost in loss record 6 of 15
==3368==    at 0x401A639: malloc (vg_replace_malloc.c:149)
==3368==    by 0x43A0D22: backtrace_symbols (in /lib/tls/libc-2.3.2.so)
==3368==    by 0x80D37DB: gw_panic (log.c:556)
==3368==    by 0x80D2294: gwlist_remove_producer (list.c:399)
==3368==    by 0x8057EDA: smsboxc_run (bb_boxc.c:1196)
==3368==    by 0x80C903F: new_thread (gwthread-pthread.c:346)
==3368==    by 0x40B6DFB: start_thread (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x438DF29: clone (in /lib/tls/libc-2.3.2.so)
==3368==
==3368==
==3368==
==3368== 2,048 bytes in 2 blocks are possibly lost in loss record 8 of 15
==3368==    at 0x401A639: malloc (vg_replace_malloc.c:149)
==3368==    by 0x401B97A: realloc (vg_replace_malloc.c:306)
==3368==    by 0x80C7E84: gw_native_realloc (gwmem-native.c:100)
==3368==    by 0x80D46F6: octstr_grow (octstr.c:190)
==3368==    by 0x80D7574: octstr_insert_data (octstr.c:1384)
==3368==    by 0x80D7769: octstr_append_data (octstr.c:1414)
==3368==    by 0x80D97C2: octstr_format_valist_real (octstr.c:2286)
==3368==    by 0x80D9731: octstr_format (octstr.c:2269)
==3368==    by 0x808B38D: handle_dlr (smsc_smpp.c:1227)
==3368==    by 0x808B80E: handle_pdu (smsc_smpp.c:1340)
==3368==    by 0x808C7D6: io_thread (smsc_smpp.c:1760)
==3368==    by 0x80C903F: new_thread (gwthread-pthread.c:346)
==3368==
==3368==
==3368== 1,236,960 (60,028 direct, 1,176,932 indirect) bytes in 2,002 blocks are definitely lost in loss record 14 o
f 15
==3368==    at 0x401A639: malloc (vg_replace_malloc.c:149)
==3368==    by 0x80C7E19: gw_native_malloc (gwmem-native.c:86)
==3368==    by 0x806089F: dlr_entry_create (dlr.c:116)
==3368==    by 0x8061512: dlr_add (dlr.c:363)
==3368==    by 0x808BC6D: handle_pdu (smsc_smpp.c:1462)
==3368==    by 0x808C7D6: io_thread (smsc_smpp.c:1760)
==3368==    by 0x80C903F: new_thread (gwthread-pthread.c:346)
==3368==    by 0x40B6DFB: start_thread (in /lib/tls/libpthread-0.60.so)
==3368==    by 0x438DF29: clone (in /lib/tls/libc-2.3.2.so)
==3368==
==3368== LEAK SUMMARY:
==3368==    definitely lost: 60,366 bytes in 2,004 blocks.
==3368==    indirectly lost: 1,176,932 bytes in 13,996 blocks.
==3368==      possibly lost: 2,268 bytes in 6 blocks.
==3368==    still reachable: 220,986 bytes in 8,376 blocks.
==3368==         suppressed: 0 bytes in 0 blocks.
==3368== Reachable blocks (those to which a pointer was found) are not shown.
==3368== To see them, rerun with: --show-reachable=yes
(END)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: valgrind - gw_check_leaks() - memory leaks etc

Loïc Minier-9
        Hi,

On Mon, Jan 23, 2006, fred wrote:
>     If someone could take a look at some of these....
>     Eg invalid read size 4 in lock....ie
>     static void lock(List *list)
>     {
>         gw_assert(list != NULL);
>         mutex_lock(list->single_operation_lock);
>     }
>     what is wrong here? anyone? and why would valgrind report this...kannel
>     seems to be working fine........

 Some memory allocations are often zeroed out or have a predictable
 content, it could explain why kannel works despite accessing
 uninitialized memory.

>     for the Question here I'm more concerned about those invalid reads...to do
>     with the library code....

 I don't understand your question.

>     ==3368== Thread 6:
>     ==3368== Invalid read of size 4
>     ==3368==    at 0x80D2683: lock (list.c:525)
>     ==3368==    by 0x80D2265: gwlist_remove_producer (list.c:398)
>     ==3368==    by 0x8057EDA: smsboxc_run (bb_boxc.c:1196)
>     ==3368==    by 0x80C903F: new_thread (gwthread-pthread.c:346)
>     ==3368==    by 0x40B6DFB: start_thread (in /lib/tls/libpthread-0.60.so)
>     ==3368==    by 0x438DF29: clone (in /lib/tls/libc-2.3.2.so)

 If this is the read you mention, then you should get a fresher kannel
 build or remove your local changes since there's no
 gwlist_remove_producer call in smsboxc_run at bb_boxc.c:1196 (in CVS).

   Cheers,

--
Loïc Minier <[hidden email]>
Current Earth status:   NOT DESTROYED

Loading...