This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Properly handle dispatch_source_set_cancel_handler with a NULL handler
ClosedPublic

Authored by kubamracek on Dec 20 2014, 11:52 PM.

Details

Reviewers
glider
Summary

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.

Diff Detail

Event Timeline

kubamracek retitled this revision from to [compiler-rt] Properly handle dispatch_source_set_cancel_handler with a NULL handler.
kubamracek updated this object.
kubamracek edited the test plan for this revision. (Show Details)
kubamracek added subscribers: Unknown Object (MLST), samsonov, kcc, glider.
glider accepted this revision.Dec 22 2014, 1:40 AM
glider added a reviewer: glider.

LGTM

This revision is now accepted and ready to land.Dec 22 2014, 1:40 AM
kubamracek closed this revision.Dec 22 2014, 9:31 AM

Landed in r224711.