From feb04d70afb8388150f2ba40df8333ca4c4817ec Mon Sep 17 00:00:00 2001 From: Igor Kudrin Date: Thu, 29 Sep 2016 06:38:06 +0000 Subject: [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 --- src/fallback_malloc.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/fallback_malloc.h (limited to 'src/fallback_malloc.h') 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 // 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 -- cgit v1.2.3