Author: dim
Date: Fri Jul 26 16:55:06 2019
New Revision: 350360
URL: https://svnweb.freebsd.org/changeset/base/350360

Log:
  Merge libcxxrt master f96846efbfd508f66d91fcbbef5dd808947c7f6d.
  
  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 (PR 239265)
  db54f53 Added C++14-specific operator delete (#47)
  
  PR:           239265
  MFC after:    3 days

Modified:
  head/contrib/libcxxrt/exception.cc   (contents, props changed)
  head/contrib/libcxxrt/memory.cc   (contents, props changed)
  head/lib/libcxxrt/Makefile
  head/lib/libcxxrt/Version.map
Directory Properties:
  head/contrib/libcxxrt/   (props changed)
  head/contrib/libcxxrt/abi_namespace.h   (props changed)
  head/contrib/libcxxrt/auxhelper.cc   (props changed)
  head/contrib/libcxxrt/cxxabi.h   (props changed)
  head/contrib/libcxxrt/dwarf_eh.h   (props changed)
  head/contrib/libcxxrt/dynamic_cast.cc   (props changed)
  head/contrib/libcxxrt/guard.cc   (props changed)
  head/contrib/libcxxrt/libelftc_dem_gnu3.c   (props changed)
  head/contrib/libcxxrt/stdexcept.cc   (props changed)
  head/contrib/libcxxrt/stdexcept.h   (props changed)
  head/contrib/libcxxrt/terminate.cc   (props changed)
  head/contrib/libcxxrt/typeinfo.cc   (props changed)
  head/contrib/libcxxrt/typeinfo.h   (props changed)

Modified: head/contrib/libcxxrt/exception.cc
==============================================================================
--- head/contrib/libcxxrt/exception.cc  Fri Jul 26 15:18:11 2019        
(r350359)
+++ head/contrib/libcxxrt/exception.cc  Fri Jul 26 16:55:06 2019        
(r350360)
@@ -879,6 +879,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
        
@@ -1224,11 +1231,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)
@@ -1365,6 +1374,14 @@ extern "C" std::type_info *__cxa_current_exception_typ
 }
 
 /**
+ * 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.
@@ -1372,6 +1389,12 @@ extern "C" std::type_info *__cxa_current_exception_typ
 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);

Modified: head/contrib/libcxxrt/memory.cc
==============================================================================
--- head/contrib/libcxxrt/memory.cc     Fri Jul 26 15:18:11 2019        
(r350359)
+++ head/contrib/libcxxrt/memory.cc     Fri Jul 26 16:55:06 2019        
(r350360)
@@ -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

Modified: head/lib/libcxxrt/Makefile
==============================================================================
--- head/lib/libcxxrt/Makefile  Fri Jul 26 15:18:11 2019        (r350359)
+++ head/lib/libcxxrt/Makefile  Fri Jul 26 16:55:06 2019        (r350360)
@@ -22,7 +22,7 @@ SRCS+=                libelftc_dem_gnu3.c\
 
 WARNS=         0
 CFLAGS+=       -isystem ${SRCDIR} -nostdinc++
-CXXSTD?=       c++11
+CXXSTD?=       c++14
 VERSION_MAP=   ${.CURDIR}/Version.map
 
 .include <bsd.lib.mk>

Modified: head/lib/libcxxrt/Version.map
==============================================================================
--- head/lib/libcxxrt/Version.map       Fri Jul 26 15:18:11 2019        
(r350359)
+++ head/lib/libcxxrt/Version.map       Fri Jul 26 16:55:06 2019        
(r350360)
@@ -277,6 +277,10 @@ CXXABI_1.3.9 {
         "typeinfo name for unsigned __int128 const*";
         "typeinfo name for unsigned __int128";
         "typeinfo name for unsigned __int128*";
+        "operator delete[](void*, unsigned int)";
+        "operator delete(void*, unsigned int)";
+        "operator delete[](void*, unsigned long)";
+        "operator delete(void*, unsigned long)";
     };
 } CXXABI_1.3.6;
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to