summaryrefslogtreecommitdiff
path: root/lib/tsan/rtl/tsan_libdispatch_mac.cc
diff options
context:
space:
mode:
authorKuba Brecka <kuba.brecka@gmail.com>2016-04-12 15:18:11 +0000
committerKuba Brecka <kuba.brecka@gmail.com>2016-04-12 15:18:11 +0000
commit96bacf0517ab241a2c0ea26127facb92032dd053 (patch)
tree9329dca3596d27c7e4d1d0071a29f9e66d35353f /lib/tsan/rtl/tsan_libdispatch_mac.cc
parent9f41c7870d5bc0f5e2162770a01e9c8a6263403d (diff)
[tsan] Fix a crash with dispatch_source_set_cancel_handler(NULL) on OS X
We need to handle the case when handler is NULL in dispatch_source_set_cancel_handler and similar interceptors. Differential Revision: http://reviews.llvm.org/D18968 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266080 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/rtl/tsan_libdispatch_mac.cc')
-rw-r--r--lib/tsan/rtl/tsan_libdispatch_mac.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/tsan/rtl/tsan_libdispatch_mac.cc b/lib/tsan/rtl/tsan_libdispatch_mac.cc
index 9f92d5eb2..30e5b4bb0 100644
--- a/lib/tsan/rtl/tsan_libdispatch_mac.cc
+++ b/lib/tsan/rtl/tsan_libdispatch_mac.cc
@@ -320,6 +320,8 @@ TSAN_INTERCEPTOR(void, dispatch_group_notify_f, dispatch_group_t group,
TSAN_INTERCEPTOR(void, dispatch_source_set_event_handler,
dispatch_source_t source, dispatch_block_t handler) {
SCOPED_TSAN_INTERCEPTOR(dispatch_source_set_event_handler, source, handler);
+ if (handler == nullptr)
+ return REAL(dispatch_source_set_event_handler)(source, nullptr);
dispatch_block_t new_handler = ^(void) {
{
SCOPED_INTERCEPTOR_RAW(dispatch_source_set_event_handler_callback);
@@ -334,6 +336,8 @@ TSAN_INTERCEPTOR(void, dispatch_source_set_event_handler,
TSAN_INTERCEPTOR(void, dispatch_source_set_event_handler_f,
dispatch_source_t source, dispatch_function_t handler) {
SCOPED_TSAN_INTERCEPTOR(dispatch_source_set_event_handler_f, source, handler);
+ if (handler == nullptr)
+ return REAL(dispatch_source_set_event_handler)(source, nullptr);
dispatch_block_t block = ^(void) {
handler(dispatch_get_context(source));
};
@@ -343,6 +347,8 @@ TSAN_INTERCEPTOR(void, dispatch_source_set_event_handler_f,
TSAN_INTERCEPTOR(void, dispatch_source_set_cancel_handler,
dispatch_source_t source, dispatch_block_t handler) {
SCOPED_TSAN_INTERCEPTOR(dispatch_source_set_cancel_handler, source, handler);
+ if (handler == nullptr)
+ return REAL(dispatch_source_set_cancel_handler)(source, nullptr);
dispatch_block_t new_handler = ^(void) {
{
SCOPED_INTERCEPTOR_RAW(dispatch_source_set_cancel_handler_callback);
@@ -358,6 +364,8 @@ TSAN_INTERCEPTOR(void, dispatch_source_set_cancel_handler_f,
dispatch_source_t source, dispatch_function_t handler) {
SCOPED_TSAN_INTERCEPTOR(dispatch_source_set_cancel_handler_f, source,
handler);
+ if (handler == nullptr)
+ return REAL(dispatch_source_set_cancel_handler)(source, nullptr);
dispatch_block_t block = ^(void) {
handler(dispatch_get_context(source));
};
@@ -368,6 +376,8 @@ TSAN_INTERCEPTOR(void, dispatch_source_set_registration_handler,
dispatch_source_t source, dispatch_block_t handler) {
SCOPED_TSAN_INTERCEPTOR(dispatch_source_set_registration_handler, source,
handler);
+ if (handler == nullptr)
+ return REAL(dispatch_source_set_registration_handler)(source, nullptr);
dispatch_block_t new_handler = ^(void) {
{
SCOPED_INTERCEPTOR_RAW(dispatch_source_set_registration_handler_callback);
@@ -383,6 +393,8 @@ TSAN_INTERCEPTOR(void, dispatch_source_set_registration_handler_f,
dispatch_source_t source, dispatch_function_t handler) {
SCOPED_TSAN_INTERCEPTOR(dispatch_source_set_registration_handler_f, source,
handler);
+ if (handler == nullptr)
+ return REAL(dispatch_source_set_registration_handler)(source, nullptr);
dispatch_block_t block = ^(void) {
handler(dispatch_get_context(source));
};