[llvm-branch-commits] [sanitizer] Fix ThreadLister::IsAlive (PR #111942)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Oct 10 20:56:45 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Vitaly Buka (vitalybuka)
<details>
<summary>Changes</summary>
'status_path_' must include `tid`.
Regression from #<!-- -->111909.
---
Full diff: https://github.com/llvm/llvm-project/pull/111942.diff
2 Files Affected:
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp (+2-1)
- (modified) compiler-rt/lib/sanitizer_common/tests/sanitizer_linux_test.cpp (+3)
``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 31750cf65ab6eb..33107eb0b42993 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -1027,7 +1027,6 @@ bool internal_sigismember(__sanitizer_sigset_t *set, int signum) {
// ThreadLister implementation.
ThreadLister::ThreadLister(pid_t pid) : buffer_(4096) {
task_path_.AppendF("/proc/%d/task", pid);
- status_path_.AppendF("%s/status", task_path_.data());
}
ThreadLister::Result ThreadLister::ListThreads(
@@ -1087,6 +1086,8 @@ ThreadLister::Result ThreadLister::ListThreads(
}
const char *ThreadLister::LoadStatus(tid_t tid) {
+ status_path_.clear();
+ status_path_.AppendF("%s/%llu/status", task_path_.data(), tid);
auto cleanup = at_scope_exit([&] {
// Resize back to capacity if it is downsized by `ReadFileToVector`.
buffer_.resize(buffer_.capacity());
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_linux_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_linux_test.cpp
index b286ab72a5c795..ce4a40444cd496 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_linux_test.cpp
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_linux_test.cpp
@@ -143,6 +143,9 @@ TEST_F(ThreadListerTest, ThreadListerSeesAllSpawnedThreads) {
std::vector<tid_t> listed_tids = ReadTidsToVector(&thread_lister);
ASSERT_TRUE(HasElement(listed_tids, self_tid));
ASSERT_TRUE(Includes(listed_tids, tids_));
+
+ ASSERT_NE(nullptr, thread_lister.LoadStatus(self_tid));
+ for (auto tid : tids_) ASSERT_NE(nullptr, thread_lister.LoadStatus(tid));
}
TEST_F(ThreadListerTest, DoNotForgetThreads) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/111942
More information about the llvm-branch-commits
mailing list