summaryrefslogtreecommitdiffstats
path: root/libcxxabi/src/cxa_exception_storage.cpp
diff options
context:
space:
mode:
authorIgor Kudrin <ikudrin.dev@gmail.com>2016-10-07 08:48:28 +0000
committerIgor Kudrin <ikudrin.dev@gmail.com>2016-10-07 08:48:28 +0000
commitd9edde4ae2cd3e5350c3a981f6715de9f2457196 (patch)
tree5a54ba1c78820fd881b810ed2fa670a029ddb5e4 /libcxxabi/src/cxa_exception_storage.cpp
parent4df1cc0b00f7ee72a1841de2080d9a4f7a1a6955 (diff)
downloadbcm5719-llvm-d9edde4ae2cd3e5350c3a981f6715de9f2457196.tar.gz
bcm5719-llvm-d9edde4ae2cd3e5350c3a981f6715de9f2457196.zip
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 llvm-svn: 283531
Diffstat (limited to 'libcxxabi/src/cxa_exception_storage.cpp')
-rw-r--r--libcxxabi/src/cxa_exception_storage.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/libcxxabi/src/cxa_exception_storage.cpp b/libcxxabi/src/cxa_exception_storage.cpp
index 235b0cf1dd3..ec69094c40c 100644
--- a/libcxxabi/src/cxa_exception_storage.cpp
+++ b/libcxxabi/src/cxa_exception_storage.cpp
@@ -45,8 +45,8 @@ extern "C" {
#else
#include <pthread.h>
-#include <cstdlib> // for calloc, free
#include "abort_message.h"
+#include "fallback_malloc.h"
// In general, we treat all pthread errors as fatal.
// We cannot call std::terminate() because that will in turn
@@ -58,7 +58,7 @@ namespace {
pthread_once_t flag_ = PTHREAD_ONCE_INIT;
void destruct_ (void *p) {
- std::free ( p );
+ __free_with_fallback ( p );
if ( 0 != ::pthread_setspecific ( key_, NULL ) )
abort_message("cannot zero out thread value for __cxa_get_globals()");
}
@@ -77,7 +77,7 @@ extern "C" {
// If this is the first time we've been asked for these globals, create them
if ( NULL == retVal ) {
retVal = static_cast<__cxa_eh_globals*>
- (std::calloc (1, sizeof (__cxa_eh_globals)));
+ (__calloc_with_fallback (1, sizeof (__cxa_eh_globals)));
if ( NULL == retVal )
abort_message("cannot allocate __cxa_eh_globals");
if ( 0 != pthread_setspecific ( key_, retVal ) )
OpenPOWER on IntegriCloud