summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc
diff options
context:
space:
mode:
authorAlex Shlyapnikov <alekseys@google.com>2018-03-28 18:22:40 +0000
committerAlex Shlyapnikov <alekseys@google.com>2018-03-28 18:22:40 +0000
commit10f50a44c1fa25463b0cb819f424abfbca336c9e (patch)
treec1513755b95befd6ad96adb89ecc0e57e32d3bca /compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc
parentb873748e151272bfe5cd3eebcf8965bb200397aa (diff)
downloadbcm5719-llvm-10f50a44c1fa25463b0cb819f424abfbca336c9e.tar.gz
bcm5719-llvm-10f50a44c1fa25463b0cb819f424abfbca336c9e.zip
[ASan] Report proper ASan error on allocator failures instead of CHECK(0)-ing
Summary: Currently many allocator specific errors (OOM, for example) are reported as a text message and CHECK(0) termination, not stack, no details, not too helpful nor informative. To improve the situation, ASan detailed errors were defined and reported under the appropriate conditions. Issue: https://github.com/google/sanitizers/issues/887 Reviewers: eugenis Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D44404 llvm-svn: 328722
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc
index 0642ee426da..61a671d149b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc
@@ -218,6 +218,10 @@ bool IsAllocatorOutOfMemory() {
return atomic_load_relaxed(&allocator_out_of_memory);
}
+void SetAllocatorOutOfMemory() {
+ atomic_store_relaxed(&allocator_out_of_memory, 1);
+}
+
// Prints error message and kills the program.
void NORETURN ReportAllocatorCannotReturnNull() {
Report("%s's allocator is terminating the process instead of returning 0\n",
@@ -258,4 +262,10 @@ void NORETURN *DieOnFailure::OnOOM() {
ReportAllocatorCannotReturnNull();
}
+// Prints hint message.
+void PrintHintAllocatorCannotReturnNull(const char *options_name) {
+ Report("HINT: if you don't care about these errors you may set "
+ "%s=allocator_may_return_null=1\n", options_name);
+}
+
} // namespace __sanitizer
OpenPOWER on IntegriCloud