path: root/lib/msan
diff options
authorAlex Shlyapnikov <>2017-06-20 21:23:02 +0000
committerAlex Shlyapnikov <>2017-06-20 21:23:02 +0000
commitc13d2469d55325c30566bff7db800053e1bca2ca (patch)
treed8d05cdb139941b1de5b28255537d1bd25e8d3f5 /lib/msan
parent4f2195f82b6124970cefd89e4ae0e179e7b99381 (diff)
[Sanitizers] Move cached allocator_may_return_null flag to sanitizer_allocator
Summary: Move cached allocator_may_return_null flag to and provide API to consolidate and unify the behavior of all specific allocators. Make all sanitizers using CombinedAllocator to follow AllocatorReturnNullOrDieOnOOM() rules to behave the same way when OOM happens. When OOM happens, turn allocator_out_of_memory flag on regardless of allocator_may_return_null flag value (it used to not to be set when allocator_may_return_null == true). release_to_os_interval_ms and rss_limit_exceeded will likely be moved to too (later). Reviewers: eugenis Subscribers: srhines, kubamracek, llvm-commits Differential Revision: git-svn-id: 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/msan')
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/msan/ b/lib/msan/
index 8d6cc69a4..d0f478afc 100644
--- a/lib/msan/
+++ b/lib/msan/
@@ -119,9 +119,8 @@ static AllocatorCache fallback_allocator_cache;
static SpinMutex fallback_mutex;
void MsanAllocatorInit() {
- allocator.Init(
- common_flags()->allocator_may_return_null,
- common_flags()->allocator_release_to_os_interval_ms);
+ SetAllocatorMayReturnNull(common_flags()->allocator_may_return_null);
+ allocator.Init(common_flags()->allocator_release_to_os_interval_ms);
AllocatorCache *GetAllocatorCache(MsanThreadLocalMallocStorage *ms) {
@@ -139,7 +138,7 @@ static void *MsanAllocate(StackTrace *stack, uptr size, uptr alignment,
if (size > kMaxAllowedMallocSize) {
Report("WARNING: MemorySanitizer failed to allocate %p bytes\n",
(void *)size);
- return allocator.ReturnNullOrDieOnBadRequest();
+ return Allocator::FailureHandler::OnBadRequest();
MsanThread *t = GetCurrentThread();
void *allocated;
@@ -197,7 +196,7 @@ void MsanDeallocate(StackTrace *stack, void *p) {
void *MsanCalloc(StackTrace *stack, uptr nmemb, uptr size) {
if (CallocShouldReturnNullDueToOverflow(size, nmemb))
- return allocator.ReturnNullOrDieOnBadRequest();
+ return Allocator::FailureHandler::OnBadRequest();
return MsanReallocate(stack, nullptr, nmemb * size, sizeof(u64), true);