[ltt-dev] [URCU] Invalid free() / delete / delete[] with valgrind

Mathieu Desnoyers compudj at krystal.dyndns.org
Tue Aug 2 13:35:25 EDT 2011


* Vegard Nossum (vegard.nossum at gmail.com) wrote:
> Hi,
> 
> With userspace-rcu-0.6.4, I get the following report with valgrind:
> 
> ==20479== Invalid free() / delete / delete[]
> ==20479==    at 0x4C21D21: free (vg_replace_malloc.c:325)
> ==20479==    by 0x51365AA: ??? (in /lib64/libc-2.5.so)
> ==20479==    by 0x51361A1: ??? (in /lib64/libc-2.5.so)
> ==20479==    by 0x4A1E4E8: _vgnU_freeres (vg_preloaded.c:62)
> ==20479==    by 0x505E4C4: exit (in /lib64/libc-2.5.so)
> ==20479==    by 0x504899A: (below main) (in /lib64/libc-2.5.so)
> ==20479==  Address 0x404f5e8 is not stack'd, malloc'd or (recently) free'd
> 
> The test-case is simply an empty main() function, no includes, nothing
> else. If I compile with -lurcu, -lurcu-bp, or -lurcu-qsbr, I get the
> warning; if I omit them, I don't.
> 
> I _guess_ it has something to do with __attribute__ ((deconstructor))

I guess you mean __attribute__ ((destructor)).

> for rcu_exit, but I am not sure. Maybe it's a libc or valgrind bug?
> 
> Did anybody else notice the same thing?

I don't get this error here:

compudj at thinkos:/tmp$ cat blah.c
int main()
{
}
compudj at thinkos:/tmp$  gcc -lurcu -o blah blah.c
compudj at thinkos:/tmp$ valgrind ./blah
==31126== Memcheck, a memory error detector
==31126== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==31126== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==31126== Command: ./blah
==31126== 
==31126== 
==31126== HEAP SUMMARY:
==31126==     in use at exit: 0 bytes in 0 blocks
==31126==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==31126== 
==31126== All heap blocks were freed -- no leaks are possible
==31126== 
==31126== For counts of detected and suppressed errors, rerun with: -v
==31126== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)

Which version of Valgrind are you using ?

For the suppressed errors, it seems to come from a glibc file:


compudj at thinkos:/tmp$ valgrind -v ./blah
==31162== Memcheck, a memory error detector
==31162== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==31162== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==31162== Command: ./blah
==31162== 
--31162-- Valgrind options:
--31162--    --suppressions=/usr/lib/valgrind/debian-libc6-dbg.supp
--31162--    -v
--31162-- Contents of /proc/version:
--31162--   Linux version 2.6.38-1-amd64 (Debian 2.6.38-1) (ben at decadent.org.uk) (gcc version 4.4.5 (Debian 4.4.5-14) ) #1 SMP Wed Mar 16 17:38:02 UTC 2011
--31162-- Arch and hwcaps: AMD64, amd64-sse3-cx16
--31162-- Page sizes: currently 4096, max supported 4096
--31162-- Valgrind library directory: /usr/lib/valgrind
--31162-- Reading syms from /tmp/blah (0x400000)
--31162-- Reading syms from /lib/ld-2.11.2.so (0x4000000)
--31162--   Considering /lib/ld-2.11.2.so ..
--31162--   .. CRC mismatch (computed cd91cee9 wanted 11b4673c)
--31162--   Considering /usr/lib/debug/lib/ld-2.11.2.so ..
--31162--   .. CRC is valid
--31162-- Reading syms from /usr/lib/valgrind/memcheck-amd64-linux (0x38000000)
--31162--    object doesn't have a dynamic symbol table
--31162-- Reading suppressions file: /usr/lib/valgrind/debian-libc6-dbg.supp
--31162-- Reading suppressions file: /usr/lib/valgrind/default.supp
--31162-- REDIR: 0x4016230 (strlen) redirected to 0x380408a7 (vgPlain_amd64_linux_REDIR_FOR_strlen)
--31162-- Reading syms from /usr/lib/valgrind/vgpreload_core-amd64-linux.so (0x4a20000)
--31162-- Reading syms from /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so (0x4c21000)
==31162== WARNING: new redirection conflicts with existing -- ignoring it
--31162--     new: 0x04016230 (strlen              ) R-> 0x04c25850 strlen
--31162-- REDIR: 0x40160a0 (index) redirected to 0x4c25460 (index)
--31162-- REDIR: 0x4016120 (strcmp) redirected to 0x4c25e30 (strcmp)
--31162-- Reading syms from /usr/local/lib/liburcu.so.1.0.0 (0x4e29000)
--31162-- Reading syms from /usr/lib/libstdc++.so.6.0.13 (0x502e000)
--31162--    object doesn't have a symbol table
--31162-- Reading syms from /lib/libm-2.11.2.so (0x5342000)
--31162--   Considering /lib/libm-2.11.2.so ..
--31162--   .. CRC mismatch (computed dd5c85df wanted ccd85fcf)
--31162--   Considering /usr/lib/debug/lib/libm-2.11.2.so ..
--31162--   .. CRC is valid
--31162-- Reading syms from /lib/libgcc_s.so.1 (0x55c4000)
--31162--   Considering /lib/libgcc_s.so.1 ..
--31162--   .. CRC mismatch (computed 07151771 wanted 3f9779e8)
--31162--    object doesn't have a symbol table
--31162-- Reading syms from /lib/libc-2.11.2.so (0x57da000)
--31162--   Considering /lib/libc-2.11.2.so ..
--31162--   .. CRC mismatch (computed 7d8e8f4f wanted 9b015f2c)
--31162--   Considering /usr/lib/debug/lib/libc-2.11.2.so ..
--31162--   .. CRC is valid
--31162-- Reading syms from /lib/libpthread-2.11.2.so (0x5b3b000)
--31162--   Considering /lib/libpthread-2.11.2.so ..
--31162--   .. CRC mismatch (computed 95ba2cd4 wanted 03f303d8)
--31162--   Considering /usr/lib/debug/lib/libpthread-2.11.2.so ..
--31162--   .. CRC is valid
--31162-- Reading syms from /usr/local/lib/liburcu-cds.so.1.0.0 (0x5d57000)
--31162-- REDIR: 0x5857600 (__GI_strrchr) redirected to 0x4c25280 (__GI_strrchr)
--31162-- REDIR: 0x58507e0 (free) redirected to 0x4c24076 (free)
==31162== 
==31162== HEAP SUMMARY:
==31162==     in use at exit: 0 bytes in 0 blocks
==31162==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==31162== 
==31162== All heap blocks were freed -- no leaks are possible
==31162== 
==31162== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)
--31162-- 
--31162-- used_suppression:      2 dl-hack3-cond-1
--31162-- used_suppression:      2 glibc-2.5.x-on-SUSE-10.2-(PPC)-2a
==31162== 
==31162== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)


Thanks,

Mathieu

> 
> 
> Vegard
> 
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
> 

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com




More information about the lttng-dev mailing list