This is an archive of the discontinued LLVM Phabricator instance.

[GWP-ASan] Add mutexes for Fuchsia
ClosedPublic

Authored by cryptoad on Oct 28 2020, 4:04 PM.

Details

Summary

Mitch expressed a preference to not have #ifdefs in platform agnostic
code, this change tries to accomodate this.

I am not attached to the method this CL proposes, so if anyone has a
suggestion, I am open.

We move the platform specific member of the mutex into its own platform
specific class that the main Mutex class inherits from. Functions are
implemented in their respective platform specific compilation units.

For Fuchsia, we use the sync APIs, as those are also the ones being
used in Scudo.

Diff Detail

Event Timeline

cryptoad created this revision.Oct 28 2020, 4:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 28 2020, 4:04 PM
Herald added subscribers: Restricted Project, phosek, mgorny. · View Herald Transcript
cryptoad requested review of this revision.Oct 28 2020, 4:04 PM
This revision is now accepted and ready to land.Oct 29 2020, 10:55 AM
hctim accepted this revision.Oct 29 2020, 2:10 PM

LGTM w/ nits.

compiler-rt/lib/gwp_asan/platform_specific/mutex_fuchsia.cpp
12

Nit: Remove #ifdefs from platform-specific code. Should only be built on that platform, so this should be unnecessary.

12

(of course i mean platform-specific cpp's here, headers obviously need the guards)

15

Nit: IWYU - please include lib/sync/mutex.h in the cpp as well.

compiler-rt/lib/gwp_asan/platform_specific/mutex_posix.h
13

Tiny nit just to be clear that "this whole file should be a nop if this isn't posix", can you move the #if defined(__unix__) into the same block as the header guards, move the endif down into the same block as the endif for the header guards, and do the same in the fuchsia header?

Like:

#if defined(__unix__)
#ifndef GWP_ASAN_MUTEX_POSIX_H_
#define GWP_ASAN_MUTEX_POSIX_H_

#include <pthread.h>

namespace ...

} // namespace ...

#endif // GWP_ASAN_MUTEX_POSIX_H_
#endif // defined(__unix__)
cryptoad updated this revision to Diff 301764.Oct 29 2020, 2:45 PM
cryptoad marked 4 inline comments as done.

Addressing review comments.

hctim accepted this revision.Oct 29 2020, 2:53 PM
This revision was landed with ongoing or failed builds.Oct 29 2020, 3:51 PM
This revision was automatically updated to reflect the committed changes.