[compiler-rt] 59b2945 - [sanitizer] Fix ThreadLister::IsAlive (#111942)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 20:57:37 PDT 2024
Author: Vitaly Buka
Date: 2024-10-10T20:57:34-07:00
New Revision: 59b2945c705671a676806b8985c3ade8d6088ab1
URL: https://github.com/llvm/llvm-project/commit/59b2945c705671a676806b8985c3ade8d6088ab1
DIFF: https://github.com/llvm/llvm-project/commit/59b2945c705671a676806b8985c3ade8d6088ab1.diff
LOG: [sanitizer] Fix ThreadLister::IsAlive (#111942)
'status_path_' must include `tid`.
Regression from #111909.
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
compiler-rt/lib/sanitizer_common/tests/sanitizer_linux_test.cpp
Removed:
################################################################################
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) {
More information about the llvm-commits
mailing list