[compiler-rt] [rtsan][compiler-rt] Prevent UB hang in rtsan lock unit tests (PR #104733)
Chris Apple via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 18 20:34:49 PDT 2024
================
@@ -328,26 +328,64 @@ TEST(TestRtsanInterceptors, PthreadCreateDiesWhenRealtime) {
ExpectNonRealtimeSurvival(Func);
}
-TEST(TestRtsanInterceptors, PthreadMutexLockDiesWhenRealtime) {
- auto Func = []() {
- pthread_mutex_t mutex{};
+class PthreadMutexLockTest : public ::testing::Test {
+protected:
+ void SetUp() override {
+ pthread_mutex_init(&mutex, nullptr);
+ is_locked = false;
+ }
+
+ void TearDown() override {
+ if (is_locked) {
+ Unlock();
+ }
+ pthread_mutex_destroy(&mutex);
+ }
+
+ void Lock() {
+ ASSERT_TRUE(!is_locked);
pthread_mutex_lock(&mutex);
----------------
cjappl wrote:
Notice here, for instance, we were locking an uninitialized lock
https://github.com/llvm/llvm-project/pull/104733
More information about the llvm-commits
mailing list