diff options
| author | Alex Shlyapnikov <alekseys@google.com> | 2017-06-16 18:48:08 +0000 |
|---|---|---|
| committer | Alex Shlyapnikov <alekseys@google.com> | 2017-06-16 18:48:08 +0000 |
| commit | 9092fe6f4b9b77a9eebc035d96ddfd5f05dc07c8 (patch) | |
| tree | e1704dc8f8cc96cd196da1e4abe856b882fa843c /compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h | |
| parent | e42e5cf8bd40cef5fce34eb9b2e26f7dac447078 (diff) | |
| download | bcm5719-llvm-9092fe6f4b9b77a9eebc035d96ddfd5f05dc07c8.tar.gz bcm5719-llvm-9092fe6f4b9b77a9eebc035d96ddfd5f05dc07c8.zip | |
[Sanitizers] Secondary allocator respects allocator_may_return_null=1.
Summary:
Context: https://github.com/google/sanitizers/issues/740.
Making secondary allocator to respect allocator_may_return_null=1 flag
and return nullptr when "out of memory" happens.
More changes in primary allocator and operator new will follow.
Reviewers: eugenis
Subscribers: kubamracek, llvm-commits
Differential Revision: https://reviews.llvm.org/D34243
llvm-svn: 305569
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h')
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h index 2e98e591b43..2c69f47ec4e 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h @@ -36,9 +36,12 @@ class LargeMmapAllocator { if (alignment > page_size_) map_size += alignment; // Overflow. - if (map_size < size) return ReturnNullOrDieOnBadRequest(); + if (map_size < size) + return ReturnNullOrDieOnBadRequest(); uptr map_beg = reinterpret_cast<uptr>( - MmapOrDie(map_size, "LargeMmapAllocator")); + MmapOrDieOnFatalError(map_size, "LargeMmapAllocator")); + if (!map_beg) + return ReturnNullOrDieOnOOM(); CHECK(IsAligned(map_beg, page_size_)); MapUnmapCallback().OnMap(map_beg, map_size); uptr map_end = map_beg + map_size; |

