[Interest] Using valgrind to detect threading errors in qt5 code

Paul Floyd paulf at free.fr
Tue Apr 10 21:44:49 CEST 2012


On 10 Apr 2012, at 14:56, Thiago Macieira wrote:

> 
> That's not correct. Valgrind's helgrind had support for QMutex specifically. 
> Helgrind needed to know when a mutex was locked or unlocked, in order to 
> present its warnings. To do that, it specifically overrides the QMutex::lock 
> and unlock functions.
> 

Thanks for the correction. The comments in the Helgrind source are quite interesting.

> I don't know about DRD.

Looking at source code, both DRD and Helgrind seem to have to same wrappers:

QMutex::QMutex(RecursionMode)
QMutex::~QMutex()
QMutex::lock()
QMutex::tryLock()
QMutex::unlock()

> As for Qt 5, since locking and unlocking is inlined into the user code, 
> valgrind might be completely unable to work.

If the code is inline, then all I can think of would be to recognise the opcode sequence and proceed from there.

A+
Paul




More information about the Interest mailing list