This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Annotate shared_mutex with thread annotations
Needs RevisionPublic

Authored by phosek on Sep 11 2019, 2:13 PM.

Details

Reviewers
EricWF
ldionne
Group Reviewers
Restricted Project
Summary

This change moves the thread annotations from __shared_mutex_base
to shared_mutex and introduces tests to ensure their functionality.

Diff Detail

Repository
rCXX libc++

Event Timeline

phosek created this revision.Sep 11 2019, 2:13 PM

When are those annotations enabled? By default they're turned off, would it make sense to turn them on by default? It seems like we're missing out on something interesting here.

ldionne accepted this revision.Sep 11 2019, 2:19 PM

But I don't have any objection with the patch itself.

This revision is now accepted and ready to land.Sep 11 2019, 2:19 PM

It would be nice to have a test (in test/libcxx) to check that these annotations are in the expected places.

ldionne added a reviewer: Restricted Project.Nov 2 2020, 3:02 PM

Ping @phosek . Are we doing this?

This revision now requires review to proceed.Nov 2 2020, 3:02 PM
ldionne requested changes to this revision.Feb 25 2021, 10:17 AM

Is there still interest in doing this? If so, I actually think we should test those annotations, perhaps by enabling them in some CI configuration (TSAN?). How can we do that? Will request changes so it shows up in the queue properly.

This revision now requires changes to proceed.Feb 25 2021, 10:17 AM
tamird added a subscriber: tamird.Apr 27 2021, 12:21 PM
phosek updated this revision to Diff 363556.Aug 2 2021, 1:20 PM
phosek retitled this revision from [libcxx] Annotate unique_lock and shared_lock with thread annotations to [libcxx] Annotate shared_mutex with thread annotations.
phosek edited the summary of this revision. (Show Details)

When are those annotations enabled? By default they're turned off, would it make sense to turn them on by default? It seems like we're missing out on something interesting here.

These are statically checked by the compiler when _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS is defined. I've included tests to cover the newly added annotations similarly to how we already test annotations on std::mutex.

ldionne requested changes to this revision.Aug 9 2021, 1:50 PM
ldionne added inline comments.
libcxx/test/libcxx/thread/thread.shared_mutex/thread_safety_missing_unlock.fail.cpp
1 ↗(On Diff #363556)

Can we make this a .verify.cpp instead?

libcxx/test/libcxx/thread/thread.shared_mutex/thread_safety_missing_unlock_shared.fail.cpp
1 ↗(On Diff #363556)

.verify.cpp

libcxx/test/libcxx/thread/thread.shared_mutex/thread_safety_requires_capability.fail.cpp
1 ↗(On Diff #363556)

.verify.cpp

38–46 ↗(On Diff #363556)

Is this actually required to trigger the error? If not, let's not have a main function at all. If so, I don't understand how this works!

This revision now requires changes to proceed.Aug 9 2021, 1:50 PM