Skip to content

Commit a7db3cb

Browse files
committed
[LSAN] Fix pthread_create interceptor to ignore leaks in real pthread_create.
Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D143209
1 parent ce63cd3 commit a7db3cb

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

compiler-rt/lib/hwasan/hwasan_interceptors.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,18 @@ static void *HwasanThreadStartFunc(void *arg) {
4040
INTERCEPTOR(int, pthread_create, void *th, void *attr, void *(*callback)(void*),
4141
void * param) {
4242
EnsureMainThreadIDIsCorrect();
43-
ScopedTaggingDisabler disabler;
43+
ScopedTaggingDisabler tagging_disabler;
4444
ThreadStartArg *A = reinterpret_cast<ThreadStartArg *> (MmapOrDie(
4545
GetPageSizeCached(), "pthread_create"));
4646
*A = {callback, param};
47-
int res = REAL(pthread_create)(th, attr, &HwasanThreadStartFunc, A);
47+
int res;
48+
{
49+
// ASAN uses the same approach to disable leaks from pthread_create.
50+
# if CAN_SANITIZE_LEAKS
51+
__lsan::ScopedInterceptorDisabler lsan_disabler;
52+
# endif
53+
res = REAL(pthread_create)(th, attr, &HwasanThreadStartFunc, A);
54+
}
4855
return res;
4956
}
5057

compiler-rt/test/lsan/TestCases/Linux/disabler_in_tsd_destructor.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// RUN: %clang_lsan %s -o %t
33
// RUN: %env_lsan_opts="report_objects=1:use_registers=0:use_stacks=0:use_tls=1:use_ld_allocations=0" %run %t
44

5-
// Fixme: remove once test passes with hwasan
6-
// UNSUPPORTED: hwasan
7-
85
#include <assert.h>
96
#include <pthread.h>
107
#include <stdio.h>

compiler-rt/test/lsan/TestCases/high_allocator_contention.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// Usage: ./a.out number_of_threads total_number_of_allocations
33
// RUN: %clangxx_lsan %s -o %t
44
// RUN: %env_lsan_opts=use_ld_allocations=0 %run %t 5 1000000 2>&1
5-
6-
// Fixme: remove once test passes with hwasan
7-
// UNSUPPORTED: hwasan
85
#include <assert.h>
96
#include <pthread.h>
107
#include <stdlib.h>

compiler-rt/test/lsan/TestCases/leak_check_before_thread_started.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// RUN: %clangxx_lsan %s -o %t
44
// RUN: %env_lsan_opts="log_pointers=1:log_threads=1" %run %t
55

6-
// Fixme: remove once test passes with hwasan
7-
// UNSUPPORTED: hwasan
8-
96
#include <assert.h>
107
#include <pthread.h>
118
#include <stdio.h>

0 commit comments

Comments
 (0)