summaryrefslogtreecommitdiff
path: root/lib/scudo/scudo_allocator_combined.h
diff options
context:
space:
mode:
authorAlex Shlyapnikov <alekseys@google.com>2017-06-20 21:23:02 +0000
committerAlex Shlyapnikov <alekseys@google.com>2017-06-20 21:23:02 +0000
commitc13d2469d55325c30566bff7db800053e1bca2ca (patch)
treed8d05cdb139941b1de5b28255537d1bd25e8d3f5 /lib/scudo/scudo_allocator_combined.h
parent4f2195f82b6124970cefd89e4ae0e179e7b99381 (diff)
[Sanitizers] Move cached allocator_may_return_null flag to sanitizer_allocator
Summary: Move cached allocator_may_return_null flag to sanitizer_allocator.cc 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 sanitizer_allocator.cc too (later). Reviewers: eugenis Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34310 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@305858 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/scudo/scudo_allocator_combined.h')
-rw-r--r--lib/scudo/scudo_allocator_combined.h18
1 files changed, 2 insertions, 16 deletions
diff --git a/lib/scudo/scudo_allocator_combined.h b/lib/scudo/scudo_allocator_combined.h
index c978db55a..21c45897b 100644
--- a/lib/scudo/scudo_allocator_combined.h
+++ b/lib/scudo/scudo_allocator_combined.h
@@ -23,11 +23,10 @@ template <class PrimaryAllocator, class AllocatorCache,
class SecondaryAllocator>
class ScudoCombinedAllocator {
public:
- void Init(bool AllocatorMayReturnNull, s32 ReleaseToOSIntervalMs) {
+ void Init(s32 ReleaseToOSIntervalMs) {
Primary.Init(ReleaseToOSIntervalMs);
- Secondary.Init(AllocatorMayReturnNull);
+ Secondary.Init();
Stats.Init();
- atomic_store_relaxed(&MayReturnNull, AllocatorMayReturnNull);
}
void *Allocate(AllocatorCache *Cache, uptr Size, uptr Alignment,
@@ -37,18 +36,6 @@ class ScudoCombinedAllocator {
return Secondary.Allocate(&Stats, Size, Alignment);
}
- void *ReturnNullOrDieOnBadRequest() {
- if (atomic_load_relaxed(&MayReturnNull))
- return nullptr;
- ReportAllocatorCannotReturnNull(false);
- }
-
- void *ReturnNullOrDieOnOOM() {
- if (atomic_load_relaxed(&MayReturnNull))
- return nullptr;
- ReportAllocatorCannotReturnNull(true);
- }
-
void Deallocate(AllocatorCache *Cache, void *Ptr, bool FromPrimary) {
if (FromPrimary)
Cache->Deallocate(&Primary, Primary.GetSizeClass(Ptr), Ptr);
@@ -78,7 +65,6 @@ class ScudoCombinedAllocator {
PrimaryAllocator Primary;
SecondaryAllocator Secondary;
AllocatorGlobalStats Stats;
- atomic_uint8_t MayReturnNull;
};
#endif // SCUDO_ALLOCATOR_COMBINED_H_