summaryrefslogtreecommitdiff
path: root/src/fallback_malloc.h
diff options
context:
space:
mode:
authorIgor Kudrin <ikudrin.dev@gmail.com>2016-09-29 06:38:06 +0000
committerIgor Kudrin <ikudrin.dev@gmail.com>2016-09-29 06:38:06 +0000
commitfeb04d70afb8388150f2ba40df8333ca4c4817ec (patch)
tree768b51034d36d5bf7d60832406dcbdbc08c74938 /src/fallback_malloc.h
parenta0863319144d468d524c8606e56ebbfb77c2bf71 (diff)
[libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.
Throwing an exception for the first time may lead to call calloc to allocate memory for __cxa_eh_globals. If the memory pool is exhausted at that moment, it results in abnormal termination of the program. This patch addresses the issue by using fallback_malloc in that case. Differential Revision: https://reviews.llvm.org/D17815 git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@282692 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'src/fallback_malloc.h')
-rw-r--r--src/fallback_malloc.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/fallback_malloc.h b/src/fallback_malloc.h
new file mode 100644
index 0000000..1078442
--- /dev/null
+++ b/src/fallback_malloc.h
@@ -0,0 +1,31 @@
+//===------------------------- fallback_malloc.h --------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _FALLBACK_MALLOC_H
+#define _FALLBACK_MALLOC_H
+
+#include <cstddef> // for size_t
+
+namespace __cxxabiv1 {
+
+#pragma GCC visibility push(hidden)
+
+// Allocate some memory from _somewhere_
+void * __malloc_with_fallback(size_t size);
+
+// Allocate and zero-initialize memory from _somewhere_
+void * __calloc_with_fallback(size_t count, size_t size);
+
+void __free_with_fallback(void *ptr);
+
+#pragma GCC visibility pop
+
+} // namespace __cxxabiv1
+
+#endif