|
From: Azat K. <doh...@gm...> - 2011-07-12 20:13:24
|
Hi every body. Now I'm trying to use annotations, to help valgrind(drd) So, I view example of usage in "drd/tests/annotate_smart_pointer.cpp", but I think it is not correct I fetch code from subversion (r11891) And now I'm trying this *g++ -o annotate_smart_pointer -lpthread -v -I`pwd`/include/ drd/tests/annotate_smart_pointer.cpp* All fine, valgrind does not report an error: $ *valgrind --tool=drd ./annotate_smart_pointer* ==11186== drd, a thread error detector ==11186== Copyright (C) 2006-2010, and GNU GPL'd, by Bart Van Assche. ==11186== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info ==11186== Command: ./annotate_smart_pointer ==11186== Done. ==11186== ==11186== For counts of detected and suppressed errors, rerun with: -v ==11186== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 18 from 14) And know, set *s_enable_annotations* to *false*: *sed -e 's/static bool s_enable_annotations = true/static bool s_enable_annotations = false/' drd/tests/annotate_smart_pointer.cpp > drd/tests/annotate_smart_pointer_wrong.cpp* And compile: *g++ -o annotate_smart_pointer_wrong -lpthread -v -I`pwd`/include/ drd/tests/annotate_smart_pointer_wrong.cpp* And now valgrind must report me an error. however: $ *valgrind --tool=drd ./annotate_smart_pointer_wrong* ==11219== drd, a thread error detector ==11219== Copyright (C) 2006-2010, and GNU GPL'd, by Bart Van Assche. ==11219== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info ==11219== Command: ./annotate_smart_pointer_wrong ==11219== Done. ==11219== ==11219== For counts of detected and suppressed errors, rerun with: -v ==11219== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 18 from 14) |
|
From: Bart V. A. <bva...@ac...> - 2011-07-13 10:21:43
|
On Tue, Jul 12, 2011 at 10:13 PM, Azat Khuzhin <doh...@gm...> wrote: > And now, set s_enable_annotations to false: > sed -e 's/static bool s_enable_annotations = true/static bool > s_enable_annotations = false/' drd/tests/annotate_smart_pointer.cpp > > drd/tests/annotate_smart_pointer_wrong.cpp Hello Azat, I'm afraid you have missed the third line in main(): s_enable_annotations = argc > 3 ? !!atoi(argv[3]) : true; So no matter which value is assigned to s_enable_annotations in the line you modified, that value is overridden by the function main(). Or: the program generated by the above sed script will run with annotations enabled, unless it is started with a third argument that is zero. The output below shows that with annotations disabled a race *is* reported: $ ./vg-in-place --tool=drd --show-confl-seg=no drd/tests/annotate_smart_pointer 1 1 0 ==3083== drd, a thread error detector ==3083== Copyright (C) 2006-2011, and GNU GPL'd, by Bart Van Assche. ==3083== Using Valgrind-3.7.0.SVN and LibVEX; rerun with -h for copyright info ==3083== Command: drd/tests/annotate_smart_pointer 1 1 0 ==3083== ==3083== Conflicting store by thread 1 at 0x0432d030 size 4 ==3083== at 0x8048F22: main (annotate_smart_pointer.cpp:273) ==3083== Address 0x432d030 is at offset 24 from 0x432d018. Allocation context: ==3083== at 0x402B44D: operator new(unsigned int) (vg_replace_malloc.c:252) ==3083== by 0x8048D6B: main (annotate_smart_pointer.cpp:316) ==3083== Done. ==3083== ==3083== For counts of detected and suppressed errors, rerun with: -v ==3083== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 18 from 6) Further feedback is welcome though. Bart. |
|
From: Azat K. <doh...@gm...> - 2011-07-13 10:26:14
|
Yes! Thanks a lot, Bart. I didn't see this! Now it is correct On Wed, Jul 13, 2011 at 2:21 PM, Bart Van Assche <bva...@ac...> wrote: > On Tue, Jul 12, 2011 at 10:13 PM, Azat Khuzhin <doh...@gm...> > wrote: > > And now, set s_enable_annotations to false: > > sed -e 's/static bool s_enable_annotations = true/static bool > > s_enable_annotations = false/' drd/tests/annotate_smart_pointer.cpp > > > drd/tests/annotate_smart_pointer_wrong.cpp > > Hello Azat, > > I'm afraid you have missed the third line in main(): > > s_enable_annotations = argc > 3 ? !!atoi(argv[3]) : true; > > So no matter which value is assigned to s_enable_annotations in the > line you modified, that value is overridden by the function main(). > Or: the program generated by the above sed script will run with > annotations enabled, unless it is started with a third argument that > is zero. > > The output below shows that with annotations disabled a race *is* reported: > > $ ./vg-in-place --tool=drd --show-confl-seg=no > drd/tests/annotate_smart_pointer 1 1 0 > ==3083== drd, a thread error detector > ==3083== Copyright (C) 2006-2011, and GNU GPL'd, by Bart Van Assche. > ==3083== Using Valgrind-3.7.0.SVN and LibVEX; rerun with -h for copyright > info > ==3083== Command: drd/tests/annotate_smart_pointer 1 1 0 > ==3083== > ==3083== Conflicting store by thread 1 at 0x0432d030 size 4 > ==3083== at 0x8048F22: main (annotate_smart_pointer.cpp:273) > ==3083== Address 0x432d030 is at offset 24 from 0x432d018. Allocation > context: > ==3083== at 0x402B44D: operator new(unsigned int) > (vg_replace_malloc.c:252) > ==3083== by 0x8048D6B: main (annotate_smart_pointer.cpp:316) > ==3083== > Done. > ==3083== > ==3083== For counts of detected and suppressed errors, rerun with: -v > ==3083== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 18 from 6) > > Further feedback is welcome though. > > Bart. > |