This is an archive of the discontinued LLVM Phabricator instance.

[Asan][Darwin][GCD] Add interceptor for dispatch_mach_create_f
ClosedPublic

Authored by thetruestblue on Jul 7 2023, 3:49 PM.

Details

Summary

When enabling DriverKit on iOS, Address Sanitizer was unable to
intercept thread creation directly for dispatch workerthreads.

Because of this calls to GetStackTraceFromID failed and ASan was
unable to capture a meaningful stack trace.

This patch adds an interceptor for a dispatch function as a proxy
that is "close enough" to thread creation so that ASan is able
to meaningfully capture and register the dispatched thread.

Note: I propose not adding a test for this change.
Because this change is only meaningful in such a narrow usecase on Darwin
and is incredibly difficult to add a meaningful test for this externally.

Diff Detail

Event Timeline

thetruestblue created this revision.Jul 7 2023, 3:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2023, 3:49 PM
Herald added a subscriber: Enna1. · View Herald Transcript
thetruestblue requested review of this revision.Jul 7 2023, 3:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2023, 3:49 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
kubamracek accepted this revision.Jul 12 2023, 10:02 AM
This revision is now accepted and ready to land.Jul 12 2023, 10:02 AM
yln accepted this revision.Jul 12 2023, 10:15 AM

LGTM, with nits:

  • Remove debugging leftover
  • Make sure to run clang-format on the modified/added parts of the file.
compiler-rt/lib/asan/asan_mac.cpp
324–327

Remove debugging leftover?

thetruestblue marked an inline comment as done.

Ran clang-format and removed debugging leftovers.

This revision was landed with ongoing or failed builds.Jul 12 2023, 8:52 PM
This revision was automatically updated to reflect the committed changes.