summaryrefslogtreecommitdiffstats
path: root/qmake/generators/win32/mingw_make.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-05-15 16:45:57 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-05-16 11:09:04 +0000
commitdb525e6e9d90350cb9778e745f43271aca4cb4e6 (patch)
treefa7858dccad407f1f88ca2aadad89a01c8a61ae8 /qmake/generators/win32/mingw_make.h
parenta0d8fb4ac3cb7bafdb39f340055eacee4f957513 (diff)
Fix race in colorspace LUT generation
The old code did not prevent concurrent writes to the LUTs by separate threads, each finding lutsGenerated to be false. Let's consider whether the change is safe now: the storeRelease(1) comes before the QMutex::unlock(), but since it is release semantics no writes may be ordered past it. We have two releases, and their order doesn't matter, since nothing else happens in-between. Could we use a normal relaxed store? No, because the unlock() of the mutex only synchronizes with the lock() of the same mutex, which doesn't happen if the loadAcquire() succeeds. For loadAcquire() to happen-before a write to the luts, we need a storeRelease() on the atomic. So, everything is correct, and minimal. But maybe, to save the next reader from having to do the same mental exercise again, add a manual locker.unlock() in front of the storeRelease()? Again no: that opens a gap where the luts are already generated on T0, and the mutex unlocked, but the atomic not set. If another thread T1 gets to execute the function, it will enter the critical section, then writing new values to the LUT. Meanwhile, the T0 sets generate to true and a T2 enters the function, sees the final write from T0 and starts using the luts -> data race with the writes concurrently done by T1. Change-Id: Id278812a74b6e326e3ddf0dbcbb94b34766aa52e Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'qmake/generators/win32/mingw_make.h')
0 files changed, 0 insertions, 0 deletions