qt5base-lts/tests/auto/corelib/thread
Marc Mutz c0251f3041 tst_QMutex: fix a race
The code uses a QSignalSpy to check whether the thread started,
but the signal emission (and subsequent appending to the spy) and
the check for spy.count() before the final thr.wait() are not
synchronized:

The signal emission happens-after the thr.start() and -before the
final thr.wait(). Likewise, the spy.count() happens-after thr.start()
and -before thr.wait(), but neither one happens-before the other.
Thus, there is a data race.

The wait(200) between thr.start() and mutex.unlock() doesn't help,
either, because we check only that it doesn't return true, iow, we
check that it timed out. But it will happily do that if the thread
has not yet started executing, so there's no happens-before relation
to be had via that avenue, either.

I first fixed by moving the spy.count() check to after thr.wait().
In that case:
  signal emission happens-before thread finishing
  happens-before thr.wait() returning
  happens-before spy.count()
so no race.

Arguably, that makes the check rather useless, so I decided to remove
it completely.

Change-Id: I6bb47c4114961ee6e9251cfebeb4b7794ba674a9
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
2013-09-23 02:47:49 +02:00
..
qatomicint Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qatomicpointer Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qfuture Whitespace cleanup: remove trailing whitespace 2013-03-16 20:22:50 +01:00
qfuturesynchronizer Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qfuturewatcher Whitespace cleanup: remove trailing whitespace 2013-03-16 20:22:50 +01:00
qmutex tst_QMutex: fix a race 2013-09-23 02:47:49 +02:00
qmutexlocker Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qreadlocker Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qreadwritelock Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qresultstore Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qsemaphore Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qthread Add an advisory interruption mechanism to QThread. 2013-09-05 08:20:18 +02:00
qthreadonce Remove QT_{BEGIN,END}_HEADER macro usage 2013-01-29 01:06:04 +01:00
qthreadpool tst_qthreadpool: fix flaky test I introduced in last commit 2013-08-29 10:25:01 +02:00
qthreadstorage Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev 2013-01-23 22:12:54 +01:00
qwaitcondition Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
qwritelocker Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
thread.pro Move QFutureSynchronizer back to QtCore 2012-09-28 23:50:10 +02:00