Bug 306612 - RHEL 6 glibc-2.X default suppressions need /lib*/libc-* patterns
Summary: RHEL 6 glibc-2.X default suppressions need /lib*/libc-* patterns
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.9.0.SVN
Platform: unspecified Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-11 13:16 UTC by Jeff Squyres
Modified: 2012-09-17 15:42 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Trivial test program; compile and run on RHEL6 to see a glibc suppression pattern that should be added to the defaults (549 bytes, application/octet-stream)
2012-09-11 13:16 UTC, Jeff Squyres
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Squyres 2012-09-11 13:16:18 UTC
Created attachment 73821 [details]
Trivial test program; compile and run on RHEL6 to see a glibc suppression pattern that should be added to the defaults

In the SVN trunk HEAD (currently: r12963), glibc-2.X.supp.in, there are many suppressions of the form:

{
   dl-hack4-64bit-addr-1
   Memcheck:Addr8
   obj:*/lib*/ld-@GLIBC_VERSION@*.so*
   obj:*/lib*/ld-@GLIBC_VERSION@*.so*
   obj:*/lib*/ld-@GLIBC_VERSION@*.so*
}
{
   dl-hack4-64bit-addr-2
   Memcheck:Addr8
   obj:*/lib*/ld-@GLIBC_VERSION@*.so*
   obj:*/lib*/ld-@GLIBC_VERSION@*.so*
   obj:*/lib*/libc-@GLIBC_VERSION@*.so*
}

Note that the only difference between the two is the library filename on the 3rd line.

But the RHEL 6-shipped glibc libraries will trip warnings in /lib*/libc-* for *all three lines*.  For example, the attached trivial test program uses the argz API in glibc.  It trips the following memcheck warning:

==29463== Invalid read of size 8
==29463==    at 0x3D5908848D: _wordcopy_fwd_dest_aligned (in /lib64/libc-2.12.so)
==29463==    by 0x3D5908211D: __GI_memmove (in /lib64/libc-2.12.so)
==29463==    by 0x3D590897DB: argz_insert (in /lib64/libc-2.12.so)
==29463==    by 0x400751: main (main.c:19)
==29463==  Address 0x4c26110 is 16 bytes inside a block of size 21 alloc'd
==29463==    at 0x4A0688E: malloc (vg_replace_malloc.c:270)
==29463==    by 0x3D5907F6E1: strdup (in /lib64/libc-2.12.so)
==29463==    by 0x4006B9: main (main.c:12)

Note that all three libraries reported are /lib64/libc-*.

At least for this specific error, another default suppression is necessary:

Index: glibc-2.X.supp.in
===================================================================
--- glibc-2.X.supp.in	(revision 12963)
+++ glibc-2.X.supp.in	(working copy)
@@ -80,6 +80,13 @@
    obj:*/lib*/libc-@GLIBC_VERSION@*.so*
 }
 {
+   dl-hack4-64bit-addr-2a
+   Memcheck:Addr8
+   obj:*/lib*/libc-@GLIBC_VERSION@*.so*
+   obj:*/lib*/libc-@GLIBC_VERSION@*.so*
+   obj:*/lib*/libc-@GLIBC_VERSION@*.so*
+}
+{
    dl-hack4-64bit-addr-3
    Memcheck:Addr8
    obj:*/lib*/ld-@GLIBC_VERSION@*.so*

I don't know if this is a wider issue or not -- it looks like the glibc-2.X.supp.in file was fairly carefully crafted, so I wouldn't want to arbitrarily just add more suppressions with all 3 libraries being */lib*/libc-*.  The attached test program shows the above error, so the patch above (or something like it) would definitely be appreciated if it could be committed for the next valgrind release.

Thanks!
Comment 1 Julian Seward 2012-09-11 13:30:22 UTC
I suspect this just fixes the symptoms.  The root problem is that __GI_memmove
didn't get intercepted as it is not listed as one of the variants of memmove that
needs to be intercepted.  Get rid of your added suppressions,
and try the patch below.  LMK if it helps or not.

Index: memcheck/mc_replace_strmem.c
===================================================================
--- memcheck/mc_replace_strmem.c	(revision 12962)
+++ memcheck/mc_replace_strmem.c	(working copy)
@@ -1020,6 +1020,7 @@
 
 #if defined(VGO_linux)
  MEMMOVE(VG_Z_LIBC_SONAME, memmove)
+ MEMMOVE(VG_Z_LIBC_SONAME, __GI_memmove)
 
 #elif defined(VGO_darwin)
 # if DARWIN_VERS <= DARWIN_10_6
Comment 2 Jeff Squyres 2012-09-11 13:37:21 UTC
I confirm that your patch fixes the issue.

Specifically: 
- I removed my extra suppression
- rebuilt valgrind with your patch
- tested it with my test program
- no warning was issued

Thank you!

(I don't know the normal modus operandi here -- should this be marked as "resolved"?)
Comment 3 Julian Seward 2012-09-11 13:46:07 UTC
No .. the bug stays open until the relevant fix lands.
Comment 4 Julian Seward 2012-09-17 15:42:21 UTC
Fixed, r12982.  Fix will be in 3.8.1.