diff options
author | Igor Kudrin <ikudrin.dev@gmail.com> | 2016-10-07 08:48:28 +0000 |
---|---|---|
committer | Igor Kudrin <ikudrin.dev@gmail.com> | 2016-10-07 08:48:28 +0000 |
commit | ace657208972b9d29bff7e062a19f59199133a4d (patch) | |
tree | 67abd4c8253423b554220f454c8b7ac327dbbcdd /src/fallback_malloc.h | |
parent | 8d4d9af454a985d8c10ffdb0c56e87efec25ddff (diff) |
Recommit r282692: [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.
In this revision, some restrictions were added into the test to not
run it in unsuitable environments.
Differential Revision: https://reviews.llvm.org/D17815
git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@283531 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'src/fallback_malloc.h')
-rw-r--r-- | src/fallback_malloc.h | 31 |
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 |