Re: [Valgrind-users] The bug that got away...

2011-11-03 Thread Julian Brown
On 2011-11-01, Peter Toft p...@linuxbog.dk wrote: Hi all Try to find the errors in this C/C++ snippet using valgrind: #include stdio.h /* Save as code.c */ int main(void) { int i=-1,a[2],b[2],c[2]; a[0] = 1; a[1] = 2; b[0] = 3; b[1] = 4; c[0] = 5; c[1] = 6; printf(%i

Re: [Valgrind-users] The bug that got away...

2011-11-03 Thread Peter Toft
On Thu, 3 Nov 2011 11:09:34 + (UTC), Julian Brown wrote: On 2011-11-01, Peter Toft wrote: Hi all Try to find the errors in this C/C++ snippet using valgrind: #include /* Save as code.c */ int main(void) { int i=-1,a[2],b[2],c[2]; a[0] = 1; a[1] = 2; b[0] = 3; b[1] = 4; c[0] = 5; c[1] =

Re: [Valgrind-users] The bug that got away...

2011-11-03 Thread Dan Kegel
On Thu, Nov 3, 2011 at 7:48 AM, Peter Toft p...@linuxbog.dk wrote: small twist to the code, then gcc -O2 -Wall finds nothing See the comment - run as code -1 #include stdio.h #include stdlib.h /* Save as code.c  compile gcc -Wall -O2 o code code.c  and run as code -1 */ int main(int

Re: [Valgrind-users] The bug that got away...

2011-11-02 Thread Peter Toft
On Wed, 02 Nov 2011 00:32:44 +, Tom Hughes wrote: On 01/11/11 22:33, Peter Toft wrote: Try to find the errors in this C/C++ snippet using valgrind: #include /* Save as code.c */ int main(void) { int i=-1,a[2],b[2],c[2]; a[0] = 1; a[1] = 2; b[0] = 3; b[1] = 4; c[0] = 5; c[1] = 6;

Re: [Valgrind-users] The bug that got away...

2011-11-02 Thread Tom Hughes
On 02/11/11 07:36, Peter Toft wrote: Valgrind _does_ point to the problematic area - but finds the problem as a unitialized values. Quite possible, depending on how the compiler chooses to arrange the stack. I did not know that the values I get with my example is different from 32 bit to 64

Re: [Valgrind-users] The bug that got away...

2011-11-02 Thread Tom Hughes
On 02/11/11 07:41, Peter Toft wrote: Actually in the future I would wish that memcheck could be extended so it could catch it - even if it would cost compile-time changes. Valgrind is a great tool, but its user-value would increase quite a bit, if it could catch a bit more (e.g. like my

Re: [Valgrind-users] The bug that got away...

2011-11-02 Thread Tom Hughes
On 02/11/11 10:18, Peter Toft wrote: I cannot see tha that other two tools do much better on this kind of coding problem. I see the same, which did surprise me a little. Maybe that I do not give valgrind sufficient amount of options. Can you comment? Well it is an experimental tool (hence

Re: [Valgrind-users] The bug that got away...

2011-11-02 Thread Julian Seward
On Wednesday, November 02, 2011 09:31:18 am Peter Toft wrote: #include /* Save as code.c */ int main(void) { int i=-1,a[2],b[2],c[2]; a[0] = 1; a[1] = 2; b[0] = 3; b[1] = 4; c[0] = 5; c[1] = 6; printf(%i %in,b[i],a[i]); return 0; } I cannot see exp-sgcheck catching anything (compiled

Re: [Valgrind-users] The bug that got away...

2011-11-02 Thread Peter Toft
On Wed, 2 Nov 2011 11:56:58 +0100, Julian Seward wrote: On Wednesday, November 02, 2011 09:31:18 am Peter Toft wrote: #include /* Save as code.c */ int main(void) { int i=-1,a[2],b[2],c[2]; a[0] = 1; a[1] = 2; b[0] = 3; b[1] = 4; c[0] = 5; c[1] = 6; printf(%i %in,b[i],a[i]); return 0; }

Re: [Valgrind-users] The bug that got away...

2011-11-02 Thread Baurzhan Ismagulov
On Tue, Nov 01, 2011 at 11:33:20PM +0100, Peter Toft wrote: int i=-1,a[2],b[2],c[2]; a[0] = 1; a[1] = 2; b[0] = 3; b[1] = 4; c[0] = 5; c[1] = 6; printf(%i %in,b[i],a[i]); ... Are there supplementary tools I should check? There is also mudflap of gcc which claims to catch exactly

Re: [Valgrind-users] The bug that got away...

2011-11-02 Thread Peter Toft
On Wed, 2 Nov 2011 13:20:55 +0100, Baurzhan Ismagulov wrote: On Tue, Nov 01, 2011 at 11:33:20PM +0100, Peter Toft wrote: int i=-1,a[2],b[2],c[2]; a[0] = 1; a[1] = 2; b[0] = 3; b[1] = 4; c[0] = 5; c[1] = 6; printf(%i %in,b[i],a[i]); ... Are there supplementary tools I should check?

Re: [Valgrind-users] The bug that got away...

2011-11-02 Thread Baurzhan Ismagulov
On Wed, Nov 02, 2011 at 01:55:50PM +0100, Peter Toft wrote: There is also mudflap of gcc which claims to catch exactly this sort of errors. I might be mistaking here but if the value if i is set from argv or alike then mudflap cannot help on this problem. It worked for me for

Re: [Valgrind-users] The bug that got away...

2011-11-02 Thread Jeffrey Walton
Hi Baurzhan, On Wed, Nov 2, 2011 at 9:34 AM, Baurzhan Ismagulov i...@radix50.net wrote: On Wed, Nov 02, 2011 at 01:55:50PM +0100, Peter Toft wrote: There is also mudflap of gcc which claims to catch exactly this sort of errors. I might be mistaking here but if the value if i is set

Re: [Valgrind-users] The bug that got away...

2011-11-02 Thread Dan Kegel
On Wed, Nov 2, 2011 at 6:55 AM, Baurzhan Ismagulov i...@radix50.net wrote: On Wed, Nov 02, 2011 at 09:42:41AM -0400, Jeffrey Walton wrote: It worked for me for overflows (e.g., i = 2) but not underflows (with -1 as in your original posting), regardless of how i has been set. That's

Re: [Valgrind-users] The bug that got away...

2011-11-02 Thread Baurzhan Ismagulov
On Wed, Nov 02, 2011 at 08:01:34AM -0700, Dan Kegel wrote: Don't forget about gcc's -fstack-protector-all option. That can find a few things. I've already tried this with the OP's example, didn't help. With kind regards, Baurzhan.

[Valgrind-users] The bug that got away...

2011-11-01 Thread Peter Toft
Hi all Try to find the errors in this C/C++ snippet using valgrind: #include stdio.h /* Save as code.c */ int main(void) { int i=-1,a[2],b[2],c[2]; a[0] = 1; a[1] = 2; b[0] = 3; b[1] = 4; c[0] = 5; c[1] = 6; printf(%i %in,b[i],a[i]); return 0; } Compile using gcc -o bla

Re: [Valgrind-users] The bug that got away...

2011-11-01 Thread Florian Krohm
On 11/01/2011 06:33 PM, Peter Toft wrote: Hi all Try to find the errors in this C/C++ snippet using valgrind: #include stdio.h /* Save as code.c */ int main(void) { int i=-1,a[2],b[2],c[2]; a[0] = 1; a[1] = 2; b[0] = 3; b[1] = 4; c[0] = 5; c[1] = 6; printf(%i

Re: [Valgrind-users] The bug that got away...

2011-11-01 Thread Tom Hughes
On 01/11/11 22:33, Peter Toft wrote: Try to find the errors in this C/C++ snippet using valgrind: #includestdio.h /* Save as code.c */ int main(void) { int i=-1,a[2],b[2],c[2]; a[0] = 1; a[1] = 2; b[0] = 3; b[1] = 4; c[0] = 5; c[1] = 6; printf(%i