aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-07-26 05:59:04 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-07-26 05:59:04 +0000
commit0d08e8ebf50805e543626b4e87157578fbad5d2b (patch)
tree714d4b9ee031dc9e2d5ca67915299a928666c729
parent44f3e9df0cdcbc4875abcd37c5783278c55fece4 (diff)
downloadsrc-vendor/libcxxrt.tar.gz
src-vendor/libcxxrt.zip
Import libcxxrt master f96846efbfd508f66d91fcbbef5dd808947c7f6d.vendor/libcxxrt
Interesting fixes: f96846e Fix std::size_t -> size_t to unbreak build against libc++ 6.0.0 6f4cfa2 Fix the uncaught exception count with rethrowing. db54f53 Added C++14-specific operator delete (#47)
Notes
Notes: svn path=/vendor/libcxxrt/dist/; revision=350348
-rw-r--r--CMakeLists.txt2
-rw-r--r--exception.cc25
-rw-r--r--memory.cc17
3 files changed, 42 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2054e4fb3214..0828ba6a342e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,7 @@ set(CXXRT_SOURCES
libelftc_dem_gnu3.c
)
-
+add_definitions(-D_GNU_SOURCE)
add_library(cxxrt-static STATIC ${CXXRT_SOURCES})
add_library(cxxrt-shared SHARED ${CXXRT_SOURCES})
target_link_libraries(cxxrt-shared ${CMAKE_DL_LIBS})
diff --git a/exception.cc b/exception.cc
index f94e95e74b0a..bad75305d586 100644
--- a/exception.cc
+++ b/exception.cc
@@ -859,6 +859,13 @@ extern "C" void __cxa_rethrow()
assert(ex->handlerCount > 0 && "Rethrowing uncaught exception!");
+ // `globals->uncaughtExceptions` was decremented by `__cxa_begin_catch`.
+ // It's normally incremented by `throw_exception`, but this path invokes
+ // `_Unwind_Resume_or_Rethrow` directly to rethrow the exception.
+ // This path is only reachable if we're rethrowing a C++ exception -
+ // foreign exceptions don't adjust any of this state.
+ globals->uncaughtExceptions++;
+
// ex->handlerCount will be decremented in __cxa_end_catch in enclosing
// catch block
@@ -1204,11 +1211,13 @@ extern "C" void *__cxa_begin_catch(void *e)
// we see is a foreign exception then we won't have called it yet.
__cxa_thread_info *ti = thread_info();
__cxa_eh_globals *globals = &ti->globals;
- globals->uncaughtExceptions--;
_Unwind_Exception *exceptionObject = static_cast<_Unwind_Exception*>(e);
if (isCXXException(exceptionObject->exception_class))
{
+ // Only exceptions thrown with a C++ exception throwing function will
+ // increment this, so don't decrement it here.
+ globals->uncaughtExceptions--;
__cxa_exception *ex = exceptionFromPointer(exceptionObject);
if (ex->handlerCount == 0)
@@ -1345,6 +1354,14 @@ extern "C" std::type_info *__cxa_current_exception_type()
}
/**
+ * Cleanup, ensures that `__cxa_end_catch` is called to balance an explicit
+ * `__cxa_begin_catch` call.
+ */
+static void end_catch(char *)
+{
+ __cxa_end_catch();
+}
+/**
* ABI function, called when an exception specification is violated.
*
* This function does not return.
@@ -1352,6 +1369,12 @@ extern "C" std::type_info *__cxa_current_exception_type()
extern "C" void __cxa_call_unexpected(void*exception)
{
_Unwind_Exception *exceptionObject = static_cast<_Unwind_Exception*>(exception);
+ // Wrap the call to the unexpected handler in calls to `__cxa_begin_catch`
+ // and `__cxa_end_catch` so that we correctly update exception counts if
+ // the unexpected handler throws an exception.
+ __cxa_begin_catch(exceptionObject);
+ __attribute__((cleanup(end_catch)))
+ char unused;
if (exceptionObject->exception_class == exception_class)
{
__cxa_exception *ex = exceptionFromPointer(exceptionObject);
diff --git a/memory.cc b/memory.cc
index 9fa9d2a7aec5..5f1aad76961f 100644
--- a/memory.cc
+++ b/memory.cc
@@ -151,4 +151,21 @@ void operator delete[](void * ptr) NOEXCEPT
::operator delete(ptr);
}
+// C++14 additional delete operators
+#if __cplusplus >= 201402L
+
+__attribute__((weak))
+void operator delete(void * ptr, size_t) NOEXCEPT
+{
+ ::operator delete(ptr);
+}
+
+
+__attribute__((weak))
+void operator delete[](void * ptr, size_t) NOEXCEPT
+{
+ ::operator delete(ptr);
+}
+
+#endif