[compiler-rt] r224711 - AddressSanitizer: Properly handle dispatch_source_set_cancel_handler with a
Kuba Brecka
kuba.brecka at gmail.com
Mon Dec 22 09:30:04 PST 2014
Author: kuba.brecka
Date: Mon Dec 22 11:30:04 2014
New Revision: 224711
URL: http://llvm.org/viewvc/llvm-project?rev=224711&view=rev
Log:
AddressSanitizer: Properly handle dispatch_source_set_cancel_handler with a
NULL handler
Per
https://developer.apple.com/library/mac/documentation/Performance/Reference/GCD_libdispatch_Ref/index.html,
the dispatch_source_set_cancel_handler() API *can* be called with a NULL
handler. In that case, the libdispatch removes an already existing cancellation
handler, if there was one. ASan's interceptor always creates a new block that
always tries to call the original handler. In case the original block is NULL,
a segmentation fault happens. Let's fix that by not wrapping a NULL-block at
all.
It looks like all the other libdispatch APIs (which we intercept) do *not*
allow NULL. So it's really only the dispatch_source_set_cancel_handler one that
needs this fix.
Reviewed at http://reviews.llvm.org/D6747
Modified:
compiler-rt/trunk/lib/asan/asan_mac.cc
Modified: compiler-rt/trunk/lib/asan/asan_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_mac.cc?rev=224711&r1=224710&r2=224711&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_mac.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_mac.cc Mon Dec 22 11:30:04 2014
@@ -403,6 +403,10 @@ INTERCEPTOR(void, dispatch_after,
INTERCEPTOR(void, dispatch_source_set_cancel_handler,
dispatch_source_t ds, void(^work)(void)) {
+ if (!work) {
+ REAL(dispatch_source_set_cancel_handler)(ds, work);
+ return;
+ }
ENABLE_FRAME_POINTER;
GET_ASAN_BLOCK(work);
REAL(dispatch_source_set_cancel_handler)(ds, asan_block);
More information about the llvm-commits
mailing list