We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
#include <bthread/bthread.h> #include <gflags/gflags.h> #include <gtest/gtest.h> namespace my::test { class TsanCheckTest : public ::testing::Test {}; int counter; std::mutex mutex_std; pthread_mutex_t mu; const int kIncrementsPerThread = 100; void* Locker(void*) { for (int i = 0; i < kIncrementsPerThread; ++i) { pthread_mutex_lock(&mu); counter++; pthread_mutex_unlock(&mu); } return nullptr; } TEST_F(TsanCheckTest, MutexUsedInPthread) { pthread_mutex_init(&mu, nullptr); const int num_threads = 8; pthread_t th[num_threads]; counter = 0; for (int i = 0; i < num_threads; ++i) { ASSERT_EQ(0, pthread_create(&th[i], nullptr, Locker, nullptr)); } for (int i = 0; i < num_threads; ++i) { ASSERT_EQ(0, pthread_join(th[i], nullptr)); } ASSERT_EQ(counter, num_threads * kIncrementsPerThread); } TEST_F(TsanCheckTest, MutexUsedInBthread) { const int num_threads = 8; bthread_t th[num_threads]; counter = 0; for (int i = 0; i < num_threads; ++i) { ASSERT_EQ(0, bthread_start_urgent(&th[i], nullptr, Locker, nullptr)); } for (int i = 0; i < num_threads; ++i) { ASSERT_EQ(0, bthread_join(th[i], nullptr)); } ASSERT_EQ(counter, num_threads * kIncrementsPerThread); } } // namespace my::test
The text was updated successfully, but these errors were encountered:
#2727 加了一个宏(NO_PTHREAD_MUTEX_HOOK)用来关掉hook。
但是bthread lock和FastPthreadLock没有适配TSan,可能会导致误报。应该得适配了TSan、ASan注解才可以正常工作吧。
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: