Bug 282979

Summary: strcasestr needs replacement with recent(>=2.12) glibc
Product: [Developer tools] valgrind Reporter: pavelo
Component: memcheckAssignee: Julian Seward <jseward>
Status: RESOLVED FIXED    
Severity: normal CC: tom
Priority: NOR    
Version: 3.6 SVN   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:

Description pavelo 2011-09-28 17:24:29 UTC
Version:           3.6 SVN
OS:                Linux

The usual problem... hyperoptimised functions produce errors when run it memcheck. The issue has been reported already (e.g here <http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg913684.html>, a patch is also available there), but as far as i can tell a fix hasn't been committed.

Reproducible: Always

Steps to Reproduce:
$ cat >foo.c <<'EOF'
  #define _GNU_SOURCE
  #include <string.h>

  int main(void)
  {
    char buf[32];

    strcpy(buf, "foo");
    return strcasestr(buf, "bar") != buf;
  }
  EOF

  $ gcc -o foo foo.c
  $ valgrind ./foo



Actual Results:  
  ==27953== Conditional jump or move depends on uninitialised value(s)
  ==27953==    at 0x4B34E2D: __strcasestr_sse42 (strstr.c:218)
  ==27953==    by 0x400519: main (in /home/peff/foo/valgrind/foo)

Expected Results:  
no errors
Comment 1 Tom Hughes 2011-09-28 18:26:37 UTC

*** This bug has been marked as a duplicate of bug 256600 ***
Comment 2 Tom Hughes 2011-09-28 18:28:00 UTC
Oops sorry, misread the function name.
Comment 3 Julian Seward 2011-10-21 08:12:35 UTC
Fixed, along with test case, r12187.  Thanks.