This is an archive of the discontinued LLVM Phabricator instance.

Remove strict tid checks from the mac implementation of BlockingMutex
ClosedPublic

Authored by fjricci on Feb 8 2017, 1:39 PM.

Details

Summary

This patch unifies the behavior of BlockingMutex on linux and mac,
resolving problems that can arise when BlockingMutex is used in
code shared by the two platforms but has different behavior depending
on the platform.

No longer requires that the calling thread own the mutex for
CheckLocked calls to pass.

Event Timeline

fjricci created this revision.Feb 8 2017, 1:39 PM

Resolves issues discussed in D29588.

dvyukov edited edge metadata.Feb 9 2017, 2:12 AM

Since we spent so much time discussion this, I guess you need to leave some traces in comments for future generations. Document what's CheckLocked contract and why it is that way.

fjricci updated this revision to Diff 87822.Feb 9 2017, 9:13 AM

Add comment explaining CheckLocked behavior

Do you have commit access? Or you want me to commit after the comment move?

lib/sanitizer_common/sanitizer_mac.cc
359

Sorry I meant comment on _declaration of the function.
This implementation is now not different from other implementations, so it does not make sense to have it here. Also a linux, or windows developers does not necessary read comments in _mac files, so he/she can change, say, windows implementation tomorrow to do the stricter check.

Kuba, this is a prerequisite for lsan on mac.

I do have commit access, thanks for checking! I'll move the comment and commit.

dvyukov accepted this revision.Feb 9 2017, 10:36 AM

LGTM if the comment is moved

This revision is now accepted and ready to land.Feb 9 2017, 10:36 AM
This revision was automatically updated to reflect the committed changes.