diff options
author | thegeorg <thegeorg@yandex-team.com> | 2025-02-28 00:07:55 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2025-02-28 00:31:16 +0300 |
commit | 56146bfad396d685118eaaec9cfff0c0675eae75 (patch) | |
tree | 74b2642cde662833ae00bac1a4e8368fef03d41c /contrib | |
parent | 811051dd0e22c2d233b46d7ac8d84d6f5de56fc8 (diff) | |
download | ydb-56146bfad396d685118eaaec9cfff0c0675eae75.tar.gz |
libcxxrt: Further adapt patch to reduce the difference with upstream
commit_hash:8b278758a3773c8420700a56ad6b239b61627d01
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/libs/cxxsupp/libcxxrt/exception.cc | 24 | ||||
-rw-r--r-- | contrib/libs/cxxsupp/libcxxrt/patches/pr41.2-fix-trace-format.patch | 26 |
2 files changed, 27 insertions, 23 deletions
diff --git a/contrib/libs/cxxsupp/libcxxrt/exception.cc b/contrib/libs/cxxsupp/libcxxrt/exception.cc index dc8d507655..088e62e449 100644 --- a/contrib/libs/cxxsupp/libcxxrt/exception.cc +++ b/contrib/libs/cxxsupp/libcxxrt/exception.cc @@ -312,19 +312,21 @@ static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c) return _URC_CONTINUE_UNWIND; } -static void bt_terminate_handler() { - __cxa_eh_globals* globals = __cxa_get_globals(); - __cxa_exception* thrown_exception = globals->caughtExceptions; +static void terminate_with_diagnostics() { + __cxa_eh_globals *globals = __cxa_get_globals(); + __cxa_exception *ex = globals->caughtExceptions; - if (thrown_exception) { - fprintf(stderr, "uncaught exception:\n address -> %p\n", (void*)thrown_exception); - thrown_exception = realExceptionFromException(thrown_exception); + if (ex != nullptr) { + fprintf(stderr, "uncaught exception:\n address -> %p\n", (void*)ex); + ex = realExceptionFromException(ex); - const __class_type_info *e_ti = static_cast<const __class_type_info*>(&typeid(std::exception)); - const __class_type_info *throw_ti = dynamic_cast<const __class_type_info*>(thrown_exception->exceptionType); + const __class_type_info *e_ti = + static_cast<const __class_type_info*>(&typeid(std::exception)); + const __class_type_info *throw_ti = + dynamic_cast<const __class_type_info*>(ex->exceptionType); if (throw_ti) { - void* ptr = thrown_exception + 1; + void* ptr = ex + 1; if (throw_ti->__do_upcast(e_ti, &ptr)) { std::exception* e = static_cast<std::exception*>(ptr); @@ -337,7 +339,7 @@ static void bt_terminate_handler() { size_t bufferSize = 128; char *demangled = static_cast<char*>(malloc(bufferSize)); - const char *mangled = thrown_exception->exceptionType->name(); + const char *mangled = ex->exceptionType->name(); int status; demangled = __cxa_demangle(mangled, demangled, &bufferSize, &status); fprintf(stderr, " type -> %s\n", status == 0 ? demangled : mangled); @@ -347,7 +349,7 @@ static void bt_terminate_handler() { } /** The global termination handler. */ -static atomic<terminate_handler> terminateHandler = bt_terminate_handler; +static atomic<terminate_handler> terminateHandler = terminate_with_diagnostics; /** The global unexpected exception handler. */ static atomic<unexpected_handler> unexpectedHandler = std::terminate; diff --git a/contrib/libs/cxxsupp/libcxxrt/patches/pr41.2-fix-trace-format.patch b/contrib/libs/cxxsupp/libcxxrt/patches/pr41.2-fix-trace-format.patch index 626d736e8b..a70c234b4f 100644 --- a/contrib/libs/cxxsupp/libcxxrt/patches/pr41.2-fix-trace-format.patch +++ b/contrib/libs/cxxsupp/libcxxrt/patches/pr41.2-fix-trace-format.patch @@ -1,22 +1,24 @@ --- contrib/libs/cxxsupp/libcxxrt/exception.cc (index) +++ contrib/libs/cxxsupp/libcxxrt/exception.cc (working tree) -@@ -312,9 +312,42 @@ static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c) +@@ -312,9 +312,44 @@ static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c) return _URC_CONTINUE_UNWIND; } -+static void bt_terminate_handler() { -+ __cxa_eh_globals* globals = __cxa_get_globals(); -+ __cxa_exception* thrown_exception = globals->caughtExceptions; ++static void terminate_with_diagnostics() { ++ __cxa_eh_globals *globals = __cxa_get_globals(); ++ __cxa_exception *ex = globals->caughtExceptions; + -+ if (thrown_exception) { -+ fprintf(stderr, "uncaught exception:\n address -> %p\n", (void*)thrown_exception); -+ thrown_exception = realExceptionFromException(thrown_exception); ++ if (ex != nullptr) { ++ fprintf(stderr, "uncaught exception:\n address -> %p\n", (void*)ex); ++ ex = realExceptionFromException(ex); + -+ const __class_type_info *e_ti = static_cast<const __class_type_info*>(&typeid(std::exception)); -+ const __class_type_info *throw_ti = dynamic_cast<const __class_type_info*>(thrown_exception->exceptionType); ++ const __class_type_info *e_ti = ++ static_cast<const __class_type_info*>(&typeid(std::exception)); ++ const __class_type_info *throw_ti = ++ dynamic_cast<const __class_type_info*>(ex->exceptionType); + + if (throw_ti) { -+ void* ptr = thrown_exception + 1; ++ void* ptr = ex + 1; + + if (throw_ti->__do_upcast(e_ti, &ptr)) { + std::exception* e = static_cast<std::exception*>(ptr); @@ -29,7 +31,7 @@ + + size_t bufferSize = 128; + char *demangled = static_cast<char*>(malloc(bufferSize)); -+ const char *mangled = thrown_exception->exceptionType->name(); ++ const char *mangled = ex->exceptionType->name(); + int status; + demangled = __cxa_demangle(mangled, demangled, &bufferSize, &status); + fprintf(stderr, " type -> %s\n", status == 0 ? demangled : mangled); @@ -40,7 +42,7 @@ /** The global termination handler. */ -static atomic<terminate_handler> terminateHandler = abort; -+static atomic<terminate_handler> terminateHandler = bt_terminate_handler; ++static atomic<terminate_handler> terminateHandler = terminate_with_diagnostics; /** The global unexpected exception handler. */ static atomic<unexpected_handler> unexpectedHandler = std::terminate; |