[compiler-rt] [rtsan] Ensure pthread is initialized in test (PR #108040)
Chris Apple via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 08:03:53 PDT 2024
https://github.com/cjappl created https://github.com/llvm/llvm-project/pull/108040
>From #107988 One of the reports was:
>
> I use Red Hat Enterprise Linux 9.0 (Plow) and Ubuntu 22.04 LTS, and the following code will work fine with Ubuntu and will segment fault for the redhat.
>
> #include <pthread.h>
> int main() {
> pthread_t thread{};
> pthread_join(thread, nullptr);
> return 0;
>
I think this could be that we are trying to join a null thread that was never created.
>From 22b6056a1b2bae1666461fd56774016096324248 Mon Sep 17 00:00:00 2001
From: Chris Apple <cja-private at pm.me>
Date: Tue, 10 Sep 2024 08:00:44 -0700
Subject: [PATCH] [rtsan] Ensure pthread is initialized in test
---
.../lib/rtsan/tests/rtsan_test_interceptors.cpp | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors.cpp b/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors.cpp
index 0eeaf9da67098e..1ef4c66a28de88 100644
--- a/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors.cpp
+++ b/compiler-rt/lib/rtsan/tests/rtsan_test_interceptors.cpp
@@ -472,11 +472,12 @@ TEST_F(PthreadMutexLockTest, PthreadMutexUnlockSurvivesWhenNotRealtime) {
ExpectNonRealtimeSurvival(Func);
}
-TEST(TestRtsanInterceptors, PthreadMutexJoinDiesWhenRealtime) {
- auto Func = []() {
- pthread_t thread{};
- pthread_join(thread, nullptr);
- };
+TEST(TestRtsanInterceptors, PthreadJoinDiesWhenRealtime) {
+ pthread_t thread{};
+ ASSERT_EQ(0,
+ pthread_create(&thread, nullptr, &FakeThreadEntryPoint, nullptr));
+
+ auto Func = [&thread]() { pthread_join(thread, nullptr); };
ExpectRealtimeDeath(Func, "pthread_join");
ExpectNonRealtimeSurvival(Func);
More information about the llvm-commits
mailing list