Public bug reported:

#include <string.h>
#include <stdio.h>
#include <stdlib.h>

main()
{
    char *a = malloc(1);
    a[0] = '\0';
    printf("%lu\n", (unsigned long)strlen(a));
}

Compile with "gcc -O2" and run valgrind.

==5977== Invalid read of size 4
==5977==    at 0x400494: main (x.c:9)
==5977==  Address 0x51ce040 is 0 bytes inside a block of size 1 alloc'd
==5977==    at 0x4C28F9F: malloc (vg_replace_malloc.c:236)
==5977==    by 0x40048D: main (x.c:7)

** Affects: valgrind (Ubuntu)
     Importance: Undecided
         Status: New

** Affects: valgrind (ALT Linux)
     Importance: Unknown
         Status: Unknown

** Affects: valgrind (Fedora)
     Importance: Unknown
         Status: Unknown


** Tags: oneiric

** Bug watch added: Red Hat Bugzilla #678518
   https://bugzilla.redhat.com/show_bug.cgi?id=678518

** Also affects: valgrind (Fedora) via
   https://bugzilla.redhat.com/show_bug.cgi?id=678518
   Importance: Unknown
       Status: Unknown

** Bug watch added: KDE Bug Tracking System #264936
   http://bugs.kde.org/show_bug.cgi?id=264936

** Also affects: valgrind (ALT Linux) via
   http://bugs.kde.org/show_bug.cgi?id=264936
   Importance: Unknown
       Status: Unknown

** Tags added: oneiric

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/852760

Title:
  valgrind false positives on gcc-generated string routines

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/valgrind/+bug/852760/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to