Skip to content

Commit a100794

Browse files
author
git apple-llvm automerger
committed
Merge commit 'f161e84c10b6' from llvm.org/master into apple/main
2 parents 48924f9 + f161e84 commit a100794

File tree

10 files changed

+24
-68
lines changed

10 files changed

+24
-68
lines changed

compiler-rt/lib/asan/asan_fuchsia.cpp

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414
#include "sanitizer_common/sanitizer_fuchsia.h"
1515
#if SANITIZER_FUCHSIA
1616

17-
#include <limits.h>
18-
#include <zircon/sanitizer.h>
19-
#include <zircon/syscalls.h>
20-
#include <zircon/threads.h>
21-
2217
#include "asan_interceptors.h"
2318
#include "asan_internal.h"
2419
#include "asan_stack.h"
2520
#include "asan_thread.h"
26-
#include "lsan/lsan_common.h"
21+
22+
#include <limits.h>
23+
#include <zircon/sanitizer.h>
24+
#include <zircon/syscalls.h>
25+
#include <zircon/threads.h>
2726

2827
namespace __asan {
2928

@@ -32,8 +31,7 @@ namespace __asan {
3231
// AsanInitInternal->InitializeHighMemEnd (asan_rtl.cpp).
3332
// Just do some additional sanity checks here.
3433
void InitializeShadowMemory() {
35-
if (Verbosity())
36-
PrintAddressSpaceLayout();
34+
if (Verbosity()) PrintAddressSpaceLayout();
3735

3836
// Make sure SHADOW_OFFSET doesn't use __asan_shadow_memory_dynamic_address.
3937
__asan_shadow_memory_dynamic_address = kDefaultShadowSentinel;
@@ -150,8 +148,7 @@ static void *BeforeThreadCreateHook(uptr user_id, bool detached,
150148
uptr stack_size) {
151149
EnsureMainThreadIDIsCorrect();
152150
// Strict init-order checking is thread-hostile.
153-
if (flags()->strict_init_order)
154-
StopInitOrderChecking();
151+
if (flags()->strict_init_order) StopInitOrderChecking();
155152

156153
GET_STACK_TRACE_THREAD;
157154
u32 parent_tid = GetCurrentTidOrInvalid();
@@ -205,18 +202,8 @@ void FlushUnneededASanShadowMemory(uptr p, uptr size) {
205202
__sanitizer_fill_shadow(p, size, 0, 0);
206203
}
207204

208-
// On Fuchsia, leak detection is done by a special hook after atexit hooks.
209-
// So this doesn't install any atexit hook like on other platforms.
210-
void InstallAtExitCheckLeaks() {}
211-
212205
} // namespace __asan
213206

214-
namespace __lsan {
215-
216-
bool UseExitcodeOnLeak() { return __asan::flags()->halt_on_error; }
217-
218-
} // namespace __lsan
219-
220207
// These are declared (in extern "C") by <zircon/sanitizer.h>.
221208
// The system runtime will call our definitions directly.
222209

compiler-rt/lib/asan/asan_internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ void *AsanDlSymNext(const char *sym);
123123
// `dlopen()` specific initialization inside this function.
124124
bool HandleDlopenInit();
125125

126-
void InstallAtExitCheckLeaks();
127-
128126
// Add convenient macro for interface functions that may be represented as
129127
// weak hooks.
130128
#define ASAN_MALLOC_HOOK(ptr, size) \

compiler-rt/lib/asan/asan_posix.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,6 @@ void PlatformTSDDtor(void *tsd) {
140140
AsanThread::TSDDtor(tsd);
141141
}
142142
#endif
143-
144-
#if CAN_SANITIZE_LEAKS
145-
void InstallAtExitCheckLeaks() {
146-
if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit) {
147-
if (flags()->halt_on_error)
148-
Atexit(__lsan::DoLeakCheck);
149-
else
150-
Atexit(__lsan::DoRecoverableLeakCheckVoid);
151-
}
152-
}
153-
#endif
154-
155143
} // namespace __asan
156144

157145
#endif // SANITIZER_POSIX

compiler-rt/lib/asan/asan_rtl.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,15 @@ static void AsanInitInternal() {
498498
force_interface_symbols(); // no-op.
499499
SanitizerInitializeUnwinder();
500500

501-
#if CAN_SANITIZE_LEAKS
502-
__lsan::InitCommonLsan();
503-
InstallAtExitCheckLeaks();
504-
#endif
501+
if (CAN_SANITIZE_LEAKS) {
502+
__lsan::InitCommonLsan();
503+
if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit) {
504+
if (flags()->halt_on_error)
505+
Atexit(__lsan::DoLeakCheck);
506+
else
507+
Atexit(__lsan::DoRecoverableLeakCheckVoid);
508+
}
509+
}
505510

506511
#if CAN_SANITIZE_UB
507512
__ubsan::InitAsPlugin();

compiler-rt/lib/asan/asan_win.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//===-- asan_win.cpp
2-
//------------------------------------------------------===//>
1+
//===-- asan_win.cpp ------------------------------------------------------===//
32
//
43
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
54
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,9 +14,10 @@
1514
#include "sanitizer_common/sanitizer_platform.h"
1615
#if SANITIZER_WINDOWS
1716
#define WIN32_LEAN_AND_MEAN
18-
#include <stdlib.h>
1917
#include <windows.h>
2018

19+
#include <stdlib.h>
20+
2121
#include "asan_interceptors.h"
2222
#include "asan_internal.h"
2323
#include "asan_mapping.h"
@@ -49,8 +49,8 @@ uptr __asan_get_shadow_memory_dynamic_address() {
4949
static LPTOP_LEVEL_EXCEPTION_FILTER default_seh_handler;
5050
static LPTOP_LEVEL_EXCEPTION_FILTER user_seh_handler;
5151

52-
extern "C" SANITIZER_INTERFACE_ATTRIBUTE long __asan_unhandled_exception_filter(
53-
EXCEPTION_POINTERS *info) {
52+
extern "C" SANITIZER_INTERFACE_ATTRIBUTE
53+
long __asan_unhandled_exception_filter(EXCEPTION_POINTERS *info) {
5454
EXCEPTION_RECORD *exception_record = info->ExceptionRecord;
5555
CONTEXT *context = info->ContextRecord;
5656

@@ -187,8 +187,6 @@ void InitializePlatformInterceptors() {
187187
}
188188
}
189189

190-
void InstallAtExitCheckLeaks() {}
191-
192190
void AsanApplyToGlobals(globals_op_fptr op, const void *needle) {
193191
UNIMPLEMENTED();
194192
}

compiler-rt/lib/lsan/lsan.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ extern "C" void __lsan_init() {
103103
InitializeThreadRegistry();
104104
InstallDeadlySignalHandlers(LsanOnDeadlySignal);
105105
InitializeMainThread();
106-
InstallAtExitCheckLeaks();
106+
107+
if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit)
108+
Atexit(DoLeakCheck);
107109

108110
InitializeCoverage(common_flags()->coverage, common_flags()->coverage_dir);
109111

compiler-rt/lib/lsan/lsan.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ namespace __lsan {
3939
void InitializeInterceptors();
4040
void ReplaceSystemMalloc();
4141
void LsanOnDeadlySignal(int signo, void *siginfo, void *context);
42-
void InstallAtExitCheckLeaks();
4342

4443
#define ENSURE_LSAN_INITED do { \
4544
CHECK(!lsan_init_is_running); \

compiler-rt/lib/lsan/lsan_common_fuchsia.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,7 @@ void ProcessPlatformSpecificAllocations(Frontier *frontier) {}
5151
// behavior and causes rare race conditions.
5252
void HandleLeaks() {}
5353

54-
// This is defined differently in asan_fuchsia.cpp and lsan_fuchsia.cpp.
55-
bool UseExitcodeOnLeak();
56-
5754
int ExitHook(int status) {
58-
if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit) {
59-
if (UseExitcodeOnLeak())
60-
DoLeakCheck();
61-
else
62-
DoRecoverableLeakCheckVoid();
63-
}
6455
return status == 0 && HasReportedLeaks() ? common_flags()->exitcode : status;
6556
}
6657

compiler-rt/lib/lsan/lsan_fuchsia.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,6 @@ void GetAllThreadAllocatorCachesLocked(InternalMmapVector<uptr> *caches) {
7676
caches);
7777
}
7878

79-
// On Fuchsia, leak detection is done by a special hook after atexit hooks.
80-
// So this doesn't install any atexit hook like on other platforms.
81-
void InstallAtExitCheckLeaks() {}
82-
83-
// ASan defines this to check its `halt_on_error` flag.
84-
bool UseExitcodeOnLeak() { return true; }
85-
8679
} // namespace __lsan
8780

8881
// These are declared (in extern "C") by <zircon/sanitizer.h>.

compiler-rt/lib/lsan/lsan_posix.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ void LsanOnDeadlySignal(int signo, void *siginfo, void *context) {
9191
nullptr);
9292
}
9393

94-
void InstallAtExitCheckLeaks() {
95-
if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit)
96-
Atexit(DoLeakCheck);
97-
}
98-
9994
} // namespace __lsan
10095

10196
#endif // SANITIZER_POSIX

0 commit comments

Comments
 (0)