diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2017-02-16 15:52:00 +0100 |
---|---|---|
committer | Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> | 2017-02-17 09:28:44 +0000 |
commit | dd7f62059c2ae52b5c05fdbe1b6b5d5fa5bc1b03 (patch) | |
tree | 200941f33952bb54f924f12abbc5abd267021d28 /src/corelib/tools/qfreelist_p.h | |
parent | 0e3d6fe4f69955bf98e23a382caf5251e2b47ea0 (diff) |
Fix a race in QFreeList
The _next variable need the acquire and release fence in next()
to synchronize with the equivalent operations in release() (which
already have the them)
The ordering on the _v[block] is not enough as this does not
synchronize the same object.
Task-number: QTBUG-58917
Change-Id: I17cc39e6791433348b6227363dbea92bcf03700d
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qfreelist_p.h')
-rw-r--r-- | src/corelib/tools/qfreelist_p.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h index c3efc41d62..a8d1132d06 100644 --- a/src/corelib/tools/qfreelist_p.h +++ b/src/corelib/tools/qfreelist_p.h @@ -237,7 +237,7 @@ inline int QFreeList<T, ConstantsType>::next() int id, newid, at; ElementType *v; do { - id = _next.load(); + id = _next.loadAcquire(); at = id & ConstantsType::IndexMask; const int block = blockfor(at); @@ -254,7 +254,7 @@ inline int QFreeList<T, ConstantsType>::next() } newid = v[at].next.load() | (id & ~ConstantsType::IndexMask); - } while (!_next.testAndSetRelaxed(id, newid)); + } while (!_next.testAndSetRelease(id, newid)); // qDebug("QFreeList::next(): returning %d (_next now %d, serial %d)", // id & ConstantsType::IndexMask, // newid & ConstantsType::IndexMask, |