[compiler-rt] [rtsan] Ensure pthread is initialized in test (PR #108040)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 08:04:27 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Chris Apple (cjappl)
<details>
<summary>Changes</summary>
>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.
---
Full diff: https://github.com/llvm/llvm-project/pull/108040.diff
1 Files Affected:
- (modified) compiler-rt/lib/rtsan/tests/rtsan_test_interceptors.cpp (+6-5)
``````````diff
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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/108040
More information about the llvm-commits
mailing list