path: root/config.tests
diff options
authorMarc Mutz <>2019-07-04 15:24:13 +0200
committerMarc Mutz <>2019-07-09 13:09:24 +0000
commit0a3107dd302c521c240b273229ba40a358cb0873 (patch)
tree2aa115fc884da90268bc8e7aba9e7e1c63421a3d /config.tests
parent1c6828b9d61a5988e91e67342cc0f616fa87949e (diff)
QHostInfo: fix a race condition on QHostInfoCache::enabled
In auto-test-enabled builds, QHostInfoCache can be enabled and disabled using qt_qhostinfo_enable_cache() at any time. We cannot rule out that users use this function, or, indeed, that the auto-test never gets a threading stress-test. Under the assumption, then, that QHostInfoCache::enabled can be set by any thread at any time, and is read by any thread using QHostInfo::lookupHost(), we're presented with a data race, thus UB. Fix by making the accesses to QHostInfoCache::enabed atomic. Relaxed operations are suffcient, as the bool is the only data of interest in these situations. In particular, access to the cache itself is protected by the cache's mutex. We use std::atomic<bool> because QAtomicInteger<bool> doesn't exist on all implementations, but std::atomic<bool> must. Commit a0faf9e2366 set the precedent that it works. Change-Id: Ia1766753bb54c5fe8d8447b51a49a96a7a853eef Reviewed-by: MÃ¥rten Nordheim <>
Diffstat (limited to 'config.tests')
0 files changed, 0 insertions, 0 deletions