Hi,

Here the problem that I have with valgrind-3.6.1-Debian (Ubuntu 11.10), 
valgrind-3.7.0 (Ubuntu 12.04) and on SVN version:

gcc -o test MallocProblemO2.cxx
valgrind --leak-check=full ./test

No problem

If I add the -O2 flag it result in a Invalid read of 4 bytes:

gcc -O2 -o test MallocProblemO2.cxx
valgrind --leak-check=full ./test

==21719== Memcheck, a memory error detector
==21719== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==21719== Using Valgrind-3.6.1-Debian and LibVEX; rerun with -h for copyright 
info
==21719== Command: ./test
==21719== 
==21719== Invalid read of size 4
==21719==    at 0x4004F0: main (in /home/kapare/Documents/test)
==21719==  Address 0x51d0044 is 4 bytes inside a block of size 6 alloc'd
==21719==    at 0x4C279F2: calloc (vg_replace_malloc.c:467)
==21719==    by 0x4004DF: main (in /home/kapare/Documents/test)
==21719== 
EXPECT STRLENGTH OF 4: 4
EXPECT STR "0123": 0123
==21719== 
==21719== HEAP SUMMARY:
==21719==     in use at exit: 0 bytes in 0 blocks
==21719==   total heap usage: 1 allocs, 1 frees, 6 bytes allocated
==21719== 
==21719== All heap blocks were freed -- no leaks are possible
==21719== 
==21719== For counts of detected and suppressed errors, rerun with: -v
==21719== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4)


This problem seem to be the same as this old one:
https://bugzilla.redhat.com/show_bug.cgi?id=518247


I have enter a bug for the issue 301922

Attachment: MallocProblemO2.cxx
Description: Binary data


Regards,

-- Kevyn-Alexandre Paré
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to