[compiler-rt] c9258ab - [LSAN] Fix pthread_create interceptor to ignore leaks in real pthread_create.
Kirill Stoimenov via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 8 14:56:05 PST 2023
Author: Kirill Stoimenov
Date: 2023-02-08T22:55:19Z
New Revision: c9258ab7f25636be24934d8727b74d9487365efe
URL: https://github.com/llvm/llvm-project/commit/c9258ab7f25636be24934d8727b74d9487365efe
DIFF: https://github.com/llvm/llvm-project/commit/c9258ab7f25636be24934d8727b74d9487365efe.diff
LOG: [LSAN] Fix pthread_create interceptor to ignore leaks in real pthread_create.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D143209
Added:
Modified:
compiler-rt/lib/hwasan/hwasan_interceptors.cpp
compiler-rt/test/lsan/TestCases/Linux/disabler_in_tsd_destructor.c
compiler-rt/test/lsan/TestCases/high_allocator_contention.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
index c1ed2cd60580..16ac85eb8589 100644
--- a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
@@ -40,11 +40,18 @@ static void *HwasanThreadStartFunc(void *arg) {
INTERCEPTOR(int, pthread_create, void *th, void *attr, void *(*callback)(void*),
void * param) {
EnsureMainThreadIDIsCorrect();
- ScopedTaggingDisabler disabler;
+ ScopedTaggingDisabler tagging_disabler;
ThreadStartArg *A = reinterpret_cast<ThreadStartArg *> (MmapOrDie(
GetPageSizeCached(), "pthread_create"));
*A = {callback, param};
- int res = REAL(pthread_create)(th, attr, &HwasanThreadStartFunc, A);
+ int res;
+ {
+ // ASAN uses the same approach to disable leaks from pthread_create.
+# if CAN_SANITIZE_LEAKS
+ __lsan::ScopedInterceptorDisabler lsan_disabler;
+# endif
+ res = REAL(pthread_create)(th, attr, &HwasanThreadStartFunc, A);
+ }
return res;
}
diff --git a/compiler-rt/test/lsan/TestCases/Linux/disabler_in_tsd_destructor.c b/compiler-rt/test/lsan/TestCases/Linux/disabler_in_tsd_destructor.c
index a590cfb8b621..6e3a9b349fc4 100644
--- a/compiler-rt/test/lsan/TestCases/Linux/disabler_in_tsd_destructor.c
+++ b/compiler-rt/test/lsan/TestCases/Linux/disabler_in_tsd_destructor.c
@@ -2,9 +2,6 @@
// RUN: %clang_lsan %s -o %t
// RUN: %env_lsan_opts="report_objects=1:use_registers=0:use_stacks=0:use_tls=1:use_ld_allocations=0" %run %t
-// Fixme: remove once test passes with hwasan
-// UNSUPPORTED: hwasan
-
#include <assert.h>
#include <pthread.h>
#include <stdio.h>
diff --git a/compiler-rt/test/lsan/TestCases/high_allocator_contention.cpp b/compiler-rt/test/lsan/TestCases/high_allocator_contention.cpp
index c3e4c01cbfb1..e1ee9ce11833 100644
--- a/compiler-rt/test/lsan/TestCases/high_allocator_contention.cpp
+++ b/compiler-rt/test/lsan/TestCases/high_allocator_contention.cpp
@@ -2,9 +2,6 @@
// Usage: ./a.out number_of_threads total_number_of_allocations
// RUN: %clangxx_lsan %s -o %t
// RUN: %env_lsan_opts=use_ld_allocations=0 %run %t 5 1000000 2>&1
-
-// Fixme: remove once test passes with hwasan
-// UNSUPPORTED: hwasan
#include <assert.h>
#include <pthread.h>
#include <stdlib.h>
More information about the llvm-commits
mailing list