forked from OSchip/llvm-project
Add support for background thread on NetBSD in ASan
Summary: Change the point of calling MaybeStartBackgroudThread() from AsanInitInternal() that is too early on NetBSD to a constructor (with aid of C++11 lambda construct). Enable the code for background thread as is for NetBSD. Rename test/sanitizer_common/TestCases/Linux/hard_rss_limit_mb_test.cc to test/sanitizer_common/TestCases/hard_rss_limit_mb_test.cc and allow runs on NetBSD. This tests passes correctly. Reviewers: vitalybuka, joerg, eugenis Reviewed By: eugenis Subscribers: eugenis, kubamracek, fedor.sergeev, llvm-commits, mgorny, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D55887 llvm-svn: 350139
This commit is contained in:
parent
adb5f1e3b5
commit
646c130a18
|
@ -383,6 +383,13 @@ void PrintAddressSpaceLayout() {
|
|||
kHighShadowBeg > kMidMemEnd);
|
||||
}
|
||||
|
||||
static bool UNUSED __local_asan_dyninit = [] {
|
||||
MaybeStartBackgroudThread();
|
||||
SetSoftRssLimitExceededCallback(AsanSoftRssLimitExceededCallback);
|
||||
|
||||
return false;
|
||||
}();
|
||||
|
||||
static void AsanInitInternal() {
|
||||
if (LIKELY(asan_inited)) return;
|
||||
SanitizerToolName = "AddressSanitizer";
|
||||
|
@ -457,9 +464,6 @@ static void AsanInitInternal() {
|
|||
allocator_options.SetFrom(flags(), common_flags());
|
||||
InitializeAllocator(allocator_options);
|
||||
|
||||
MaybeStartBackgroudThread();
|
||||
SetSoftRssLimitExceededCallback(AsanSoftRssLimitExceededCallback);
|
||||
|
||||
// On Linux AsanThread::ThreadStart() calls malloc() that's why asan_inited
|
||||
// should be set to 1 prior to initializing the threads.
|
||||
asan_inited = 1;
|
||||
|
|
|
@ -25,7 +25,7 @@ void SetSoftRssLimitExceededCallback(void (*Callback)(bool exceeded)) {
|
|||
SoftRssLimitExceededCallback = Callback;
|
||||
}
|
||||
|
||||
#if SANITIZER_LINUX && !SANITIZER_GO
|
||||
#if (SANITIZER_LINUX || SANITIZER_NETBSD) && !SANITIZER_GO
|
||||
// Weak default implementation for when sanitizer_stackdepot is not linked in.
|
||||
SANITIZER_WEAK_ATTRIBUTE StackDepotStats *StackDepotGetStats() {
|
||||
return nullptr;
|
||||
|
@ -114,7 +114,7 @@ void WriteToSyslog(const char *msg) {
|
|||
}
|
||||
|
||||
void MaybeStartBackgroudThread() {
|
||||
#if SANITIZER_LINUX && \
|
||||
#if (SANITIZER_LINUX || SANITIZER_NETBSD) && \
|
||||
!SANITIZER_GO // Need to implement/test on other platforms.
|
||||
// Start the background thread if one of the rss limits is given.
|
||||
if (!common_flags()->hard_rss_limit_mb &&
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
// https://github.com/google/sanitizers/issues/981
|
||||
// UNSUPPORTED: android-26
|
||||
|
||||
// UNSUPPORTED: freebsd, solaris, darwin
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
Loading…
Reference in New Issue