[Interest] Using valgrind to detect threading errors in qt5 code
Paul Floyd
paulf at free.fr
Tue Apr 10 22:46:38 CEST 2012
On 10 Apr 2012, at 22:28, Thiago Macieira wrote:
> On terça-feira, 10 de abril de 2012 21.44.49, Paul Floyd wrote:
>>> 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.
>
> It's very hard to distinguish a "lock cmpxchg" sequence doing locking from the
> same code sequence doing something else, like allocating a timer ID in the
> lock-free QFreeList.
I imagine that there is more than just that one opcode to the lock.
If there isn't an unique signature, then one could be made using the technique used by the Valgrind client request macros: a signature sequence of opcodes [4 'rol edi's that sum to 64 bits of rotation, leaving edi unchanged] that would 'never' be emitted by a compiler is inserted inline. The downside is that this would require either a special build of Qt or a small overhead if always built in (and I expect that the lock/unlock code is rather performance critical).
A+
Paul
More information about the Interest
mailing list