On Saturday, August 25, 2012, David Faure wrote: > How do I tell helgrind that some atomic operations on integers are OK? > [...]
Without looking in more detail at this, it is difficult to tell if that is really the right question to ask. Helgrind treats atomic operations (atomic read-modify-write) as if they were simply reads, both for x86/x86_64, and similarly for LL/SC pairs on ARM, PPC, MIPS, etc. So it should not report races on code that uses atomic operations. Now, that said, a reason it might be reporting races like this is that Qt is using the atomic ops to create inter-thread synchronisation that Helgrind cannot see, hence it reports a race where there is none. Or maybe Qt really is racey -- perhaps harmlessly. In which case H is correct to complain. Without looking further, it's not really possible to say what's happening. I would be happy to do that if you make it easy (viz, send commands starting with "wget qt5.tarball" etc) to build a simple test case. One way to hide the complaints is use VALGRIND_{DISABLE,ENABLE}_ERROR_REPORTING around the affected areas. Read the docs in valgrind.h about that. Or you can use VALGRIND_HG_{DISABLE,ENABLE}_CHECKING on the address range (in helgrind.h) to tell H not to check the particular address range. That's quite dangerous though because you need be sure to re-enable checking on the range when the memory is freed. Both of those approaches are basically bad though, because they might hide real bugs, both in Qt and in apps linked against it. Better to investigate what is going on here, fix any bugs found, and mark up Qt to notify Helgrind/DRD of any inter-thread synchronisation that the normal pthread intercepts cannot see. Once that is done, it should be possible to use Helgrind/DRD on Qt without false errors. That could be complex though, because it may involve describing the synchronisation induced by thread-safe reference counting. That's doable -- I marked up Firefox's XPCOM implementation so it can be Helgrinded, so I know it is possible. LMK if I can help more. J ------------------------------------------------------------------------------ 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 Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users