From: Bart V. A. <bva...@ac...> - 2012-08-25 10:30:56
|
On 08/25/12 08:45, David Faure wrote: > How do I tell helgrind that some atomic operations on integers are OK? > > A suppression like this works, but it would make helgrind more useful to all Qt users if either atomic operations were handled automatically, or if this was added to valgrind's own suppressions. > > { > qt5_basic_atomic_integer > Helgrind:Race > fun:_ZNK19QBasicAtomicIntegerIiE4loadEv > } > > Also, this only works for integers, not for pointers... > > ==8489== Possible data race during read of size 8 at 0x8B9C968 by thread #3 > ==8489== at 0x57549C0: QBasicAtomicPointer<QTextCodec>::loadAcquire() const (qgenericatomic.h:110) > ==8489== by 0x5753A26: QTextCodec::codecForLocale() (qtextcodec.cpp:683) > ==8489== by 0x558BD08: QString::toLocal8Bit() const (qstring.cpp:3959) > ==8489== > ==8489== This conflicts with a previous write of size 8 by thread #2 > ==8489== at 0x57549A2: QBasicAtomicPointer<QTextCodec>::storeRelease(QTextCodec*) (qgenericatomic.h:119) > ==8489== by 0x5757D5D: QIcuCodec::defaultCodecUnlocked() (qicucodec.cpp:441) > ==8489== by 0x5753A43: QTextCodec::codecForLocale() (qtextcodec.cpp:687) > ==8489== by 0x558BD08: QString::toLocal8Bit() const (qstring.cpp:3959) > > Can't make suppressions for these, given that the template class could use any type > (here QTextCodec). > > The implementation of loadAcquire/storeRelease is compiler and platform dependent. > With C++11 it uses std::atomic, with gcc (in non-c++11 mode) it uses some __sync_synchronize stuff, > on ARM there's a bit of assembly, etc. > > I presume all this is too low-level for helgrind? I.e. can it actually detect atomic operations > and therefore validate Qt's implementation, or should we rather just "trust Qt" and aim for > silencing helgrind whenever it sees QBasicAtomic{Integer,Pointer}? The Qt authors will have to modify the Qt library somewhat before it will become convenient to analyze Qt programs with Helgrind or DRD. See also this bug report (created three years ago): http://bugreports.qt-project.org/browse/QTBUG-5655. Bart. |