Hi all,

I am trying to solve some hard-to-find issue with valgrind (which I
use regularly and is a great tool, BTW :)). As memcheck does not find
anything, I gave exp-ptrcheck a try.

While the program is memcheck-clean, I get lots of violations and have
not yet managed to find any failure in my code (what obviously does
not mean there are none;)). It looks like some machine instructions
used by glibc trigger these violations. Many are inside the
string-library (like strcmp()) and show sizes of 8 or 16. To me, it
almost looks like the string library is using extended load operations
which then cause this problem.

To "fix" one of these situations, I changed a strchr() call. Code
snippet is as follows:

#if 1
                        pModDirNext = (uchar *)strchr((char *)pModDirCurr, ':');
#else
                        for(pModDirNext = pModDirCurr
                            ; *pModDirNext != '\0' && *pModDirNext != ':'
                            ; pModDirNext++)
                                ; /*DO NOTHING - all done in for() header*/
#endif


If I use strchr(), this violation is displayed:

==5980== Invalid read of size 16
==5980==    at 0x303E27D838: __GI_strchr (in /lib64/libc-2.11.1.so)
==5980==    by 0x4219A7: Load (modules.c:639)
==5980==    by 0x41FE7F: UseObj (obj.c:1156)
==5980==    by 0x4136DF: confClassInit (conf.c:1293)
==5980==    by 0x412B33: rsrtInit (rsyslog.c:185)
==5980==    by 0x40CB85: realMain (syslogd.c:2912)
==5980==    by 0x303E21EB1C: (below main) (in /lib64/libc-2.11.1.so)
==5980==  Address 0x4c26440 is 16 bytes inside the accessing pointer's
==5980==  legitimate range, a block of size 31 alloc'd
==5980==    at 0x4A046DD: malloc (vg_replace_malloc.c:195)
==5980==    by 0x303E27F021: strdup (in /lib64/libc-2.11.1.so)
==5980==    by 0x4211DE: SetModDir (modules.c:745)
==5980==    by 0x421279: moduleClassInit (modules.c:887)
==5980==    by 0x41F6BF: objClassInit (obj.c:1337)
==5980==    by 0x412907: rsrtInit (rsyslog.c:139)
==5980==    by 0x40CB85: realMain (syslogd.c:2912)
==5980==    by 0x303E21EB1C: (below main) (in /lib64/libc-2.11.1.so)
==5980==

If I  use my replacement code, no violation is displayed.

I am using valgrind 3.5.0 on amd64. Any help on this issue would be
deeply appreciated.

Thanks,
Rainer

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to