[compiler-rt] 25feff4 - [sanitizer] Start background thread once
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 2 11:45:41 PST 2021
Author: Vitaly Buka
Date: 2021-12-02T11:45:37-08:00
New Revision: 25feff4b2e815aeda777368625fb75e52a77753a
URL: https://github.com/llvm/llvm-project/commit/25feff4b2e815aeda777368625fb75e52a77753a
DIFF: https://github.com/llvm/llvm-project/commit/25feff4b2e815aeda777368625fb75e52a77753a.diff
LOG: [sanitizer] Start background thread once
Reviewed By: morehouse
Differential Revision: https://reviews.llvm.org/D114933
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
index bc4b477e350f..0a065fefb814 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
@@ -29,6 +29,7 @@ void SetSoftRssLimitExceededCallback(void (*Callback)(bool exceeded)) {
SANITIZER_WEAK_ATTRIBUTE StackDepotStats StackDepotGetStats() { return {}; }
void *BackgroundThread(void *arg) {
+ VPrintf(1, "%s: Started BackgroundThread\n", SanitizerToolName);
const uptr hard_rss_limit_mb = common_flags()->hard_rss_limit_mb;
const uptr soft_rss_limit_mb = common_flags()->soft_rss_limit_mb;
const bool heap_profile = common_flags()->heap_profile;
@@ -112,8 +113,16 @@ void MaybeStartBackgroudThread() {
if (!common_flags()->hard_rss_limit_mb &&
!common_flags()->soft_rss_limit_mb &&
!common_flags()->heap_profile) return;
- if (!&real_pthread_create) return; // Can't spawn the thread anyway.
- internal_start_thread(BackgroundThread, nullptr);
+ if (!&real_pthread_create) {
+ VPrintf(1, "%s: real_pthread_create undefined\n", SanitizerToolName);
+ return; // Can't spawn the thread anyway.
+ }
+
+ static bool started = false;
+ if (!started) {
+ started = true;
+ internal_start_thread(BackgroundThread, nullptr);
+ }
#endif
}
More information about the llvm-commits
mailing list