registrar: Fix race condition on MimeUpdateThread termination.hrev49570
commit462bfeede0cd123afe2e79d465876289e925ca53
authorMichael Lotz <mmlr@mlotz.ch>
Sun, 23 Aug 2015 09:48:24 +0000 (23 11:48 +0200)
committerMichael Lotz <mmlr@mlotz.ch>
Sun, 23 Aug 2015 10:30:35 +0000 (23 12:30 +0200)
tree80005b492d3a35fbc63b3d5a5272b4642ac02fba
parentdfb3208fa3856c5c6d582fb826b7c991c67fa54d
registrar: Fix race condition on MimeUpdateThread termination.

When the MimeUpdateThread is done, it marks itself as finished and
notifies the thread manager to clean up finished threads. Since multiple
such threads might finish at the same time and trigger the cleanup
notification, other threads that already marked themselves finished but
haven't actually exited yet might already be deleted and removed. This
would then lead to a use-after-free when they subsequently tried to send
their own cleanup message.

To solve the race condition, the thread manager will now wait for the
thread to actually exit before cleaning it up.

The introduction of the launch_daemon has made this race condition more
likely due to more applications starting in parallel, each triggering a
CreateAppMetaMimeThread which is a subclass of MimeUpdateThread. This
commit might therefore fix #12237.
src/servers/registrar/mime/RegistrarThreadManager.cpp