-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clang Thread Safety Analysis warnings in time_controller_clock.cpp #795
Comments
I don't see a bugs reported by this warnings in the code, rather this is a bug in our tooling environment. @sloretz @emersonknapp How to know which version of the According to the https://stackoverflow.com/a/38442968 the thread-safety annotations became included in the
It looks like our As regards to the warning from
This is really false positive in thread safety analysis. Because according to the https://en.cppreference.com/w/cpp/thread/condition_variable/notify_all
We shouldn't call |
The version we are using is what is shipped with Ubuntu 20.04; it gets installed in the Dockerfile here. Checking locally, it looks like it is probably I am fairly confident that version supports thread annotations; the entire reason we stood up that clang-libcxx job in the first place was to test out thread annotations. I think @emersonknapp set up that job, so he may have more details. |
@MichaelOrlov the standard |
@emersonknapp This is not about reproduction of the issue. I am clearly understand what these issues about and that this job running nightly. According to the my analysis our libcxx version doesn't know about thread safety annotations and this is why we have warnings from thread safety analysis when trying to use thread safety annotations with Please refer to the https://stackoverflow.com/a/38442968 the thread-safety annotations became included in the libcxx since March 15, 2016. per libcxx Add clang thread safety annotations to mutex and lock_guard PR. |
The question is why it isn't working with the version of libc++-10 in Ubuntu 20.04. That version was released in March 2020, so it is clearly new enough to have the PRs you referenced incorporated. So the possibilities seem to be:
I don't know which of those is the case, but that's what we need to figure out. |
Was this upgraded in the last 2 weeks? I'm sure it's what we've been running the entire time. And it supports the thread safety analysis. We were successfully using these annotations in Bionic for the Dashing release. I'm confused what the confusion is. The buildfarm and default Focal installations support this feature, and are correctly pointing out that the code is wrong.
The thread safety analysis checks have been working the entire time, as you will notice there are already annotations in the PlayerClock code - the newest warnings were introduced, as @clalancette said, in #779 - in https://ci.ros2.org/view/nightly/job/nightly_linux_clang_libcxx/818/ there were only warnings from If you look at the warnings that the CI shows you https://ci.ros2.org/view/nightly/job/nightly_linux_clang_libcxx/819/clang/folder.535941802/source.5d4ff16c-783b-4241-a873-4a9e5dc3e2c2/#143 - it's clear that yes, you are accessing the variable |
It doesn't look like it; the last Ubuntu build of this package in 20.04 was in April: https://launchpad.net/ubuntu/+source/llvm-toolchain-10 |
@emersonknapp @clalancette I've tried to dig deeper as much I can on my side in this issue, and here is my observation:
void process_callbacks_before_jump(const rcl_time_jump_t & time_jump)
{
std::lock_guard<std::mutex> lock(callback_list_mutex_);
for (auto const & handler : callback_list_) {
process_callback(handler, time_jump, true);
}
}
void process_callbacks_after_jump(const rcl_time_jump_t & time_jump)
{
std::lock_guard<std::mutex> lock(callback_list_mutex_);
for (auto const & handler : callback_list_) {
process_callback(handler, time_jump, false);
}
} As you can see, there obviously taking
template <class _Mutex>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable)
lock_guard
{
public:
typedef _Mutex mutex_type;
private:
mutex_type& __m_;
public:
_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY
explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
: __m_(__m) {__m_.lock();}
_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY
lock_guard(mutex_type& __m, adopt_lock_t) _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
: __m_(__m) {}
_LIBCPP_INLINE_VISIBILITY
~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) {__m_.unlock();}
private:
lock_guard(lock_guard const&) _LIBCPP_EQUAL_DELETE;
lock_guard& operator=(lock_guard const&) _LIBCPP_EQUAL_DELETE;
};
|
@emersonknapp @clalancette it seems I was digging in wrong direction. Sorry about confusion. I see that in the same file we also using I see one significant difference in my case which might affect thread safety analysis I can try to prepare PR with removing What do you think? |
@clalancette @emersonknapp |
Closing this issue as resolved since 799 has been merged. |
Description
The latest
nightly_linux_clang_libcxx
job shows new thread safety analysis warnings.Expected Behavior
No thread safety analysis warnings
Actual Behavior
Clang reports thread safety analysis warnings
To Reproduce
time_controller_clock.cpp
warningsSystem (please complete the following information)
master
/ bb9c7aeAdditional context
All the offending code appears to come from this commit 6f7503e #779
The text was updated successfully, but these errors were encountered: