[PATCH] D21999: [tsan] Fix false positives with GCD dispatch_source_*
Kuba Brecka via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 5 09:21:44 PDT 2016
kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, kcc, glider.
kubabrecka added subscribers: llvm-commits, zaks.anna, dcoughlin.
kubabrecka added a project: Sanitizers.
Herald added a subscriber: kubabrecka.
We already have interceptors for dispatch_source API (e.g. dispatch_source_set_event_handler), but they currently only handle submission synchronization. We also need to synchronize based on the target queue (serial, concurrent), in other words, we need to use `dispatch_callback_wrap`. This patch implements that.
However, some more magic is needed for this to work, because the callback set in dispatch_source_set_event_handler is called multiple times (to the contrary of most other GCD APIs), so we cannot free() the context in the callback. The lifetime of the context and the wrapper block needs to be inherited from the outer block (the one actually submitted to `REAL(dispatch_source_set_event_handler)`), so we need to *capture* the original handler *and* the context. The `Block_copy` is needed to make sure the `__block tsan_block_context_t new_context` is converted to a heap-allocated object.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 5347 bytes
Desc: not available
More information about the llvm-commits