[Valgrind-users] Invalid read raised with stpncpy

2012-08-12 Thread Francis Giraldeau
Hi, Valgrind reports an invalid read, while I think the program is valid. The program uses stpncpy() instead of strcpy(): #include string.h #include stdlib.h #include stdio.h int main(int argc, char **argv) { char *dst = (char *) calloc(4, 1); char *src = (char *) calloc(4, 1);

Re: [Valgrind-users] Invalid read raised with stpncpy

2012-08-12 Thread songbird
Francis Giraldeau wrote: ... Hi, Valgrind reports an invalid read, while I think the program is valid. The program uses stpncpy() instead of strcpy(): #include string.h #include stdlib.h #include stdio.h int main(int argc, char **argv) { char *dst =3D (char *) calloc(4, 1);

Re: [Valgrind-users] Invalid read raised with stpncpy

2012-08-12 Thread Francis Giraldeau
Le 2012-08-12 17:41, songbird a écrit : Francis Giraldeau wrote: ... Hi, Valgrind reports an invalid read, while I think the program is valid. The program uses stpncpy() instead of strcpy(): #include string.h #include stdlib.h #include stdio.h int main(int argc, char **argv) {

Re: [Valgrind-users] Invalid read raised with stpncpy

2012-08-12 Thread Philippe Waroquiers
On Sun, 2012-08-12 at 18:10 +0200, Francis Giraldeau wrote: Of course you are right! Thought, I just tested without updating dst and the problem is raised anyway. The error is not caused in the printf(), but in the stpncpy(). String functions might be optimised very specially by the compiler

Re: [Valgrind-users] Invalid read raised with stpncpy

2012-08-12 Thread Francis Giraldeau
Le 2012-08-12 18:56, Philippe Waroquiers a écrit : On Sun, 2012-08-12 at 18:10 +0200, Francis Giraldeau wrote: Of course you are right! Thought, I just tested without updating dst and the problem is raised anyway. The error is not caused in the printf(), but in the stpncpy(). String functions

Re: [Valgrind-users] Invalid read raised with stpncpy

2012-08-12 Thread Philippe Waroquiers
On Sun, 2012-08-12 at 19:15 +0200, Francis Giraldeau wrote: I confirm this too. I did a trivial implementation of stpcpy/stpncpy with strcpy and it do not raise the issue. Maybe they can be a basis for an additional REDIR? The best is to file a bug on bugzilla, with the test program to

Re: [Valgrind-users] Invalid read raised with stpncpy

2012-08-12 Thread Patrick J. LoPresti
On Sun, Aug 12, 2012 at 11:03 AM, Philippe Waroquiers philippe.waroqui...@skynet.be wrote: On Sun, 2012-08-12 at 19:15 +0200, Francis Giraldeau wrote: The best is to file a bug on bugzilla, with the test program to reproduce the false positive and additional details such as gcc version,

Re: [Valgrind-users] Invalid read raised with stpncpy

2012-08-12 Thread John Reiser
The correct fix for this problem is to set --partial-loads-ok=yes. Perhaps not for all purposes. The original traceback for _this_ case: ==21946== Invalid read of size 8 ==21946==at 0x4ECA554: __stpncpy_sse2_unaligned (strcpy-sse2-unaligned.S:297) implicates hand-written

Re: [Valgrind-users] Invalid read raised with stpncpy

2012-08-12 Thread Patrick J. LoPresti
On Sun, Aug 12, 2012 at 1:44 PM, John Reiser jrei...@bitwagon.com wrote: memcheck implements intercepting re-directs for both strcpy and strncpy. The re-directs remove the possibility of any false positive complaints, and also are significantly faster than emulating instructions. Therefore,

Re: [Valgrind-users] Invalid read raised with stpncpy

2012-08-12 Thread John Reiser
On 08/12/2012 06:44 PM, Patrick J. LoPresti wrote: Or, you know, we could instead spend effort fixing Valgrind's machine emulator to match the memory model of real machines. Your idea of real machine is not the same as mine. --

Re: [Valgrind-users] Invalid read raised with stpncpy

2012-08-12 Thread Patrick J. LoPresti
On Sun, Aug 12, 2012 at 7:10 PM, John Reiser jrei...@bitwagon.com wrote: On 08/12/2012 06:44 PM, Patrick J. LoPresti wrote: Or, you know, we could instead spend effort fixing Valgrind's machine emulator to match the memory model of real machines. Your idea of real machine is not the same