@@ -103,8 +103,6 @@ void FlushUnneededASanShadowMemory(uptr p, uptr size) {
103
103
// dispatch_after()
104
104
// dispatch_group_async_f()
105
105
// dispatch_group_async()
106
- // dispatch_apply()
107
- // dispatch_apply_f()
108
106
// TODO(glider): libdispatch API contains other functions that we don't support
109
107
// yet.
110
108
//
@@ -130,7 +128,6 @@ typedef void* dispatch_queue_t;
130
128
typedef void * dispatch_source_t ;
131
129
typedef u64 dispatch_time_t ;
132
130
typedef void (*dispatch_function_t )(void *block);
133
- typedef void (*dispatch_apply_function_t )(void *, size_t );
134
131
typedef void * (*worker_t )(void *block);
135
132
typedef unsigned long dispatch_mach_reason;
136
133
typedef void *dispatch_mach_msg_t ;
@@ -150,11 +147,7 @@ typedef void (^dispatch_mach_handler_t)(dispatch_mach_reason reason,
150
147
// A wrapper for the ObjC blocks used to support libdispatch.
151
148
typedef struct {
152
149
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;
158
151
u32 parent_tid;
159
152
} asan_block_context_t ;
160
153
@@ -182,8 +175,8 @@ void asan_dispatch_call_block_and_release(void *block) {
182
175
block, (void *)pthread_self ());
183
176
asan_register_worker_thread (context->parent_tid , &stack);
184
177
// 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 );
187
180
}
188
181
189
182
} // namespace __asan
@@ -198,7 +191,7 @@ asan_block_context_t *alloc_asan_context(void *ctxt, dispatch_function_t func,
198
191
asan_block_context_t *asan_ctxt =
199
192
(asan_block_context_t *) asan_malloc (sizeof (asan_block_context_t ), stack);
200
193
asan_ctxt->block = ctxt;
201
- asan_ctxt->dispatch_func = func;
194
+ asan_ctxt->func = func;
202
195
asan_ctxt->parent_tid = GetCurrentTidOrInvalid ();
203
196
return asan_ctxt;
204
197
}
@@ -250,34 +243,13 @@ INTERCEPTOR(void, dispatch_group_async_f, dispatch_group_t group,
250
243
asan_dispatch_call_block_and_release);
251
244
}
252
245
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)
273
247
extern " C" {
274
248
void dispatch_async (dispatch_queue_t dq, void (^work)(void ));
275
249
void dispatch_group_async (dispatch_group_t dg, dispatch_queue_t dq,
276
250
void (^work)(void ));
277
251
void dispatch_after (dispatch_time_t when, dispatch_queue_t queue,
278
252
void (^work)(void ));
279
- void dispatch_apply (size_t iterations, dispatch_queue_t queue,
280
- void (^block)(size_t iteration));
281
253
void dispatch_source_set_cancel_handler (dispatch_source_t ds,
282
254
void (^work)(void ));
283
255
void 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,
360
332
});
361
333
}
362
334
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
378
336
379
337
#endif // SANITIZER_APPLE
0 commit comments