|
From: Jesper F. <jes...@si...> - 2011-11-12 23:10:04
|
Dear all,
I get "Invalid read of size 8" in strspn(). The error can be reproduced by the following small program on Fedora 15 (glibc-2.14-5.x86_64):
$ cat valtest.c
#include <stdlib.h>
#include <string.h>
int main()
{
char *s = strdup(" ");
int n = strspn("abc", s);
free(s);
return n;
}
$ gcc -g -Wall valtest.c -o valtest
$ valgrind valtest
==20722== Memcheck, a memory error detector
==20722== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==20722== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==20722== Command: valtest
==20722==
==20722== Invalid read of size 8
==20722== at 0x3D3432735C: __strspn_sse42 (in /lib64/libc-2.14.so)
==20722== by 0x40057A: main (valtest.c:7)
==20722== Address 0x4c37040 is 0 bytes inside a block of size 2 alloc'd
==20722== at 0x4A0649D: malloc (vg_replace_malloc.c:236)
==20722== by 0x3D34280611: strdup (in /lib64/libc-2.14.so)
==20722== by 0x400565: main (valtest.c:6)
==20722==
==20722==
==20722== HEAP SUMMARY:
==20722== in use at exit: 0 bytes in 0 blocks
==20722== total heap usage: 1 allocs, 1 frees, 2 bytes allocated
==20722==
==20722== All heap blocks were freed -- no leaks are possible
==20722==
==20722== For counts of detected and suppressed errors, rerun with: -v
==20722== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 6 from 6)
Is this safe to suppress this with the following?
{
Invalid read of size 8 in strspn
Memcheck:Addr8
fun:__strspn_sse42
...
}
Best regards
/Jesper
|