summaryrefslogtreecommitdiff
path: root/lib/msan/msan_allocator.cc
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-09-29 21:28:54 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-09-29 21:28:54 +0000
commit89fbf48c3f234712be522e62591a9cb137adb69d (patch)
tree6ba0e7091e3a079c7c7171af80d9d8e0f5f283e1 /lib/msan/msan_allocator.cc
parent380cd5916e0b30615c5a006b6097574725e62603 (diff)
[msan] Early allocator initialization.
Map MSan heap space early (in __msan_init) so that user code can not accidentally (i.e. w/o MAP_FIXED) create a conflicting mapping. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@248829 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/msan/msan_allocator.cc')
-rw-r--r--lib/msan/msan_allocator.cc10
1 files changed, 1 insertions, 9 deletions
diff --git a/lib/msan/msan_allocator.cc b/lib/msan/msan_allocator.cc
index b713c66b9..006d993f0 100644
--- a/lib/msan/msan_allocator.cc
+++ b/lib/msan/msan_allocator.cc
@@ -87,12 +87,7 @@ static Allocator allocator;
static AllocatorCache fallback_allocator_cache;
static SpinMutex fallback_mutex;
-static int inited = 0;
-
-static inline void Init() {
- if (inited) return;
- __msan_init();
- inited = true; // this must happen before any threads are created.
+void MsanAllocatorInit() {
allocator.Init(common_flags()->allocator_may_return_null);
}
@@ -108,7 +103,6 @@ void MsanThreadLocalMallocStorage::CommitBack() {
static void *MsanAllocate(StackTrace *stack, uptr size, uptr alignment,
bool zeroise) {
- Init();
if (size > kMaxAllowedMallocSize) {
Report("WARNING: MemorySanitizer failed to allocate %p bytes\n",
(void *)size);
@@ -143,7 +137,6 @@ static void *MsanAllocate(StackTrace *stack, uptr size, uptr alignment,
void MsanDeallocate(StackTrace *stack, void *p) {
CHECK(p);
- Init();
MSAN_FREE_HOOK(p);
Metadata *meta = reinterpret_cast<Metadata *>(allocator.GetMetaData(p));
uptr size = meta->requested_size;
@@ -170,7 +163,6 @@ void MsanDeallocate(StackTrace *stack, void *p) {
}
void *MsanCalloc(StackTrace *stack, uptr nmemb, uptr size) {
- Init();
if (CallocShouldReturnNullDueToOverflow(size, nmemb))
return allocator.ReturnNullOrDie();
return MsanReallocate(stack, 0, nmemb * size, sizeof(u64), true);