[compiler-rt] a7db3cb - [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 12:36:46 PST 2023
Author: Kirill Stoimenov
Date: 2023-02-08T20:36:35Z
New Revision: a7db3cb257ff6396481f44427bccd0ca5abf4d63
URL: https://github.com/llvm/llvm-project/commit/a7db3cb257ff6396481f44427bccd0ca5abf4d63
DIFF: https://github.com/llvm/llvm-project/commit/a7db3cb257ff6396481f44427bccd0ca5abf4d63.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
compiler-rt/test/lsan/TestCases/leak_check_before_thread_started.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
index c1ed2cd60580c..16ac85eb85894 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 a590cfb8b621a..6e3a9b349fc4e 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 c3e4c01cbfb14..e1ee9ce11833a 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>
diff --git a/compiler-rt/test/lsan/TestCases/leak_check_before_thread_started.cpp b/compiler-rt/test/lsan/TestCases/leak_check_before_thread_started.cpp
index 68eea93a81e57..04f23878ca009 100644
--- a/compiler-rt/test/lsan/TestCases/leak_check_before_thread_started.cpp
+++ b/compiler-rt/test/lsan/TestCases/leak_check_before_thread_started.cpp
@@ -3,9 +3,6 @@
// RUN: %clangxx_lsan %s -o %t
// RUN: %env_lsan_opts="log_pointers=1:log_threads=1" %run %t
-// Fixme: remove once test passes with hwasan
-// UNSUPPORTED: hwasan
-
#include <assert.h>
#include <pthread.h>
#include <stdio.h>
More information about the llvm-commits
mailing list