@@ -103,8 +103,6 @@ void FlushUnneededASanShadowMemory(uptr p, uptr size) {
103103// dispatch_after()
104104// dispatch_group_async_f()
105105// dispatch_group_async()
106- // dispatch_apply()
107- // dispatch_apply_f()
108106// TODO(glider): libdispatch API contains other functions that we don't support
109107// yet.
110108//
@@ -130,7 +128,6 @@ typedef void* dispatch_queue_t;
130128typedef void * dispatch_source_t ;
131129typedef u64 dispatch_time_t ;
132130typedef void (*dispatch_function_t )(void *block);
133- typedef void (*dispatch_apply_function_t )(void *, size_t );
134131typedef void * (*worker_t )(void *block);
135132typedef unsigned long dispatch_mach_reason;
136133typedef void *dispatch_mach_msg_t ;
@@ -150,11 +147,7 @@ typedef void (^dispatch_mach_handler_t)(dispatch_mach_reason reason,
150147// A wrapper for the ObjC blocks used to support libdispatch.
151148typedef struct {
152149 void *block;
153- union {
154- dispatch_function_t dispatch_func;
155- dispatch_apply_function_t dispatch_apply_func;
156- static_assert (sizeof (dispatch_func) == sizeof (dispatch_apply_func));
157- };
150+ dispatch_function_t func;
158151 u32 parent_tid;
159152} asan_block_context_t ;
160153
@@ -182,8 +175,8 @@ void asan_dispatch_call_block_and_release(void *block) {
182175 block, (void *)pthread_self ());
183176 asan_register_worker_thread (context->parent_tid , &stack);
184177 // Call the original dispatcher for the block.
185- context->dispatch_func (context->block );
186- asan_free (context, &stack);
178+ context->func (context->block );
179+ asan_free (context, &stack, FROM_MALLOC );
187180}
188181
189182} // namespace __asan
@@ -198,7 +191,7 @@ asan_block_context_t *alloc_asan_context(void *ctxt, dispatch_function_t func,
198191 asan_block_context_t *asan_ctxt =
199192 (asan_block_context_t *) asan_malloc (sizeof (asan_block_context_t ), stack);
200193 asan_ctxt->block = ctxt;
201- asan_ctxt->dispatch_func = func;
194+ asan_ctxt->func = func;
202195 asan_ctxt->parent_tid = GetCurrentTidOrInvalid ();
203196 return asan_ctxt;
204197}
@@ -250,34 +243,13 @@ INTERCEPTOR(void, dispatch_group_async_f, dispatch_group_t group,
250243 asan_dispatch_call_block_and_release);
251244}
252245
253- extern " C" void asan_dispatch_apply_f_work (void *context, size_t iteration) {
254- GET_STACK_TRACE_THREAD;
255- asan_block_context_t *asan_ctxt = (asan_block_context_t *)context;
256- asan_register_worker_thread (asan_ctxt->parent_tid , &stack);
257- asan_ctxt->dispatch_apply_func (asan_ctxt->block , iteration);
258- }
259-
260- INTERCEPTOR (void , dispatch_apply_f, size_t iterations, dispatch_queue_t queue,
261- void *ctxt, dispatch_apply_function_t work) {
262- GET_STACK_TRACE_THREAD;
263- asan_block_context_t *asan_ctxt =
264- (asan_block_context_t *)asan_malloc (sizeof (asan_block_context_t ), &stack);
265- asan_ctxt->block = ctxt;
266- asan_ctxt->dispatch_apply_func = work;
267- asan_ctxt->parent_tid = GetCurrentTidOrInvalid ();
268- REAL (dispatch_apply_f)(iterations, queue, (void *)asan_ctxt,
269- asan_dispatch_apply_f_work);
270- }
271-
272- # if !defined(MISSING_BLOCKS_SUPPORT)
246+ #if !defined(MISSING_BLOCKS_SUPPORT)
273247extern " C" {
274248void dispatch_async (dispatch_queue_t dq, void (^work)(void ));
275249void dispatch_group_async (dispatch_group_t dg, dispatch_queue_t dq,
276250 void (^work)(void ));
277251void dispatch_after (dispatch_time_t when, dispatch_queue_t queue,
278252 void (^work)(void ));
279- void dispatch_apply (size_t iterations, dispatch_queue_t queue,
280- void (^block)(size_t iteration));
281253void dispatch_source_set_cancel_handler (dispatch_source_t ds,
282254 void (^work)(void ));
283255void dispatch_source_set_event_handler (dispatch_source_t ds, void (^work)(void ));
@@ -360,20 +332,6 @@ INTERCEPTOR(void *, dispatch_mach_create_f, const char *label,
360332 });
361333}
362334
363- INTERCEPTOR (void , dispatch_apply, size_t iterations, dispatch_queue_t queue,
364- void (^block)(size_t iteration)) {
365- ENABLE_FRAME_POINTER;
366- int parent_tid = GetCurrentTidOrInvalid ();
367-
368- void (^asan_block)(size_t ) = ^(size_t iteration) {
369- GET_STACK_TRACE_THREAD;
370- asan_register_worker_thread (parent_tid, &stack);
371- block (iteration);
372- };
373-
374- REAL (dispatch_apply)(iterations, queue, asan_block);
375- }
376-
377- # endif
335+ #endif
378336
379337#endif // SANITIZER_APPLE
0 commit comments