[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#456303: __libc_freeres error valgrind with shared libraries with multiple --rpath



Package: libc6
Version: 2.7-4
Severity: normal

--- Please enter the report below this line. ---

I get this valgring warning:
==3759== Invalid free() / delete / delete[]
==3759==    at 0x4C21B2E: free (vg_replace_malloc.c:323)
==3759==    by 0x53EDA2A: (within /lib/libc-2.7.so)
==3759==    by 0x53ED5F8: __libc_freeres (in /lib/libc-2.7.so)
==3759==    by 0x4A1E31C: _vgnU_freeres (vg_preloaded.c:60)
==3759==    by 0x5313036: exit (in /lib/libc-2.7.so)
==3759==    by 0x52FC1CA: (below main) (in /lib/libc-2.7.so)
==3759==  Address 0x4034f18 is not stack'd, malloc'd or (recently)
free'd

According to valgrind manual this is a bug present in old glibcs.
However I am using glibc 2.7, and this warnings started showing up
only very recently.
I tried both valgrind 3.3.0-1 and 3.2.3-3, and they show same
behaviour with latest libc.

Valgrind or glibc bug?

Steps to reproduce:
Originally observed as: build clamav, run clamscan under valgrind,
watch valgrind output at the end.

Reduced steps:

Run the commands below in an empty directory:

mkdir .libs
mkdir  lib2/.libs
cat >empty.c <<EOF
int main(){}
EOF
 gcc -c empty.c  -fPIC -DPIC -o .libs/empty.o
gcc -shared  .libs/empty.o  -Wl,--rpath -Wl,lib2/.libs  -lnsl
-Wl,-soname -Wl,libclamav.so.3 -o .libs/libclamav.so.3.0.3
(cd .libs && rm -f libclamav.so.3 && ln -s libclamav.so.3.0.3
libclamav.so.3)
(cd .libs && rm -f libclamav.so && ln -s libclamav.so.3.0.3
libclamav.so)
gcc -o a.out empty.c .libs/libclamav.so  -Wl,--rpath -Wl,.libs
valgrind ./a.out

Notice that if I remove -lnsl, or the 2nd --rpath (lib2/.libs) I
no longer get the warning.

My output is:

$ sh -x ./steps
+ mkdir .libs
+ mkdir lib2/.libs
mkdir: cannot create directory `lib2/.libs': No such file or directory
+ cat
+ gcc -c empty.c -fPIC -DPIC -o .libs/empty.o
+ gcc -shared .libs/empty.o -Wl,--rpath -Wl,lib2/.libs -lnsl
-Wl,-soname -Wl,libclamav.so.3 -o .libs/libclamav.so.3.0.3
+ cd .libs
+ rm -f libclamav.so.3
+ ln -s libclamav.so.3.0.3 libclamav.so.3
+ cd .libs
+ rm -f libclamav.so
+ ln -s libclamav.so.3.0.3 libclamav.so
+ gcc -o a.out empty.c .libs/libclamav.so -Wl,--rpath -Wl,.libs
+ valgrind ./a.out
==1204== Memcheck, a memory error detector.
==1204== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==1204== Using LibVEX rev 1804, a library for dynamic binary
translation.
==1204== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==1204== Using valgrind-3.3.0-Debian, a dynamic binary
instrumentation framework.
==1204== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==1204== For more details, rerun with: -v
==1204==
==1204== Invalid free() / delete / delete[]
==1204==    at 0x4A06B2E: free (vg_replace_malloc.c:323)
==1204==    by 0x4F1BA2A: free_mem (dl-libc.c:235)
==1204==    by 0x4F1B5F8: __libc_freeres (set-freeres.c:47)
==1204==    by 0x480331C: _vgnU_freeres (vg_preloaded.c:60)
==1204==    by 0x4E41036: exit (exit.c:90)
==1204==    by 0x4E2A1CA: (below main) (libc-start.c:254)
==1204==  Address 0x516a000 is not stack'd, malloc'd or (recently)
free'd
==1204==
==1204== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 8 from 1)
==1204== malloc/free: in use at exit: 0 bytes in 0 blocks.
==1204== malloc/free: 0 allocs, 1 frees, 0 bytes allocated.
==1204== For counts of detected errors, rerun with: -v
==1204== All heap blocks were freed -- no leaks are possible.


--- System information. ---
Architecture: amd64
Kernel:       Linux 2.6.23-rc8-hrt1-cfs-v22-g1bef7dc0-dirty

Debian Release: lenny/sid
  500 unstable        www.debian-multimedia.org
  500 unstable        ftp.iasi.roedu.net
  500 testing         ftp.iasi.roedu.net
  500 gutsy           wine.budgetdedicated.com
    1 experimental    ftp.iasi.roedu.net

--- Package information. ---
Depends       (Version) | Installed
=======================-+-===========
libgcc1                 | 1:4.2.2-4





Reply to: