Diffusion Krita 64dc4d5b7431

Fix a race condition in KisLocklessStack

Authored by dkazakov on Mar 21 2019, 12:22 PM.

Description

Fix a race condition in KisLocklessStack

When recycling the objects after pop(), a race condition could happen.
After the thread has successfully passed 'if (m_deleteBlockers == 1)'
check, it could go to sleep. During its sleep some other threads could
release more objects into m_freeNodes, which were still accessed by
someone. It could lead to both: invalid access or even ABA problem
(the latter, theoretically, could cause bug 405663).

The patch fixes the problem by forcing the releasing thread to check
if it is still the only owner of the freeNodes list. It atomically
fetches the list of free nodes, and only after that checks if all its
other users are dead. Since the list is stored in a local variable,
it is guaranteed that noone modifies it during the check.

BUG:405663

Details

Committed
dkazakovMar 21 2019, 12:22 PM
Parents
R37:0c15ea90cb9f: Add quazip to snap and lgtm definitions
Branches
Unknown
Tags
Unknown