FreeBSD Bugzilla – Attachment 170805 Details for
Bug 204786
devel/libcxxrt: crash when mixing different languages with exceptions (Affects databases/tarantool)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch brings upstream patch to fix it (with a little portlint fix)
patch-devel_libcxxrt.diff (text/plain), 7.89 KB, created by
Mahdi Mokhtari
on 2016-05-29 17:45:39 UTC
(
hide
)
Description:
patch brings upstream patch to fix it (with a little portlint fix)
Filename:
MIME Type:
Creator:
Mahdi Mokhtari
Created:
2016-05-29 17:45:39 UTC
Size:
7.89 KB
patch
obsolete
>Index: devel/libcxxrt/files/patch-src_exception.cc >=================================================================== >--- devel/libcxxrt/files/patch-src_exception.cc (nonexistent) >+++ devel/libcxxrt/files/patch-src_exception.cc (working copy) >@@ -0,0 +1,48 @@ >+--- src/exception.cc.orig 2013-12-26 03:11:27 UTC >++++ src/exception.cc >+@@ -304,13 +304,17 @@ static pthread_key_t eh_key; >+ static void exception_cleanup(_Unwind_Reason_Code reason, >+ struct _Unwind_Exception *ex) >+ { >+- __cxa_free_exception(static_cast<void*>(ex)); >++ // Exception layout: >++ // [__cxa_exception [_Unwind_Exception]] [exception object] >++ // >++ // __cxa_free_exception expects a pointer to the exception object >++ __cxa_free_exception(static_cast<void*>(ex + 1)); >+ } >+ static void dependent_exception_cleanup(_Unwind_Reason_Code reason, >+ struct _Unwind_Exception *ex) >+ { >+ >+- __cxa_free_dependent_exception(static_cast<void*>(ex)); >++ __cxa_free_dependent_exception(static_cast<void*>(ex + 1)); >+ } >+ >+ /** >+@@ -340,7 +344,8 @@ static void thread_cleanup(void* thread_ >+ if (info->foreign_exception_state != __cxa_thread_info::none) >+ { >+ _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(info->globals.caughtExceptions); >+- e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); >++ if (e->exception_cleanup) >++ e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); >+ } >+ else >+ { >+@@ -1270,12 +1275,13 @@ extern "C" void __cxa_end_catch() >+ >+ if (ti->foreign_exception_state != __cxa_thread_info::none) >+ { >+- globals->caughtExceptions = 0; >+ if (ti->foreign_exception_state != __cxa_thread_info::rethrown) >+ { >+ _Unwind_Exception *e = reinterpret_cast<_Unwind_Exception*>(ti->globals.caughtExceptions); >+- e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); >++ if (e->exception_cleanup) >++ e->exception_cleanup(_URC_FOREIGN_EXCEPTION_CAUGHT, e); >+ } >++ globals->caughtExceptions = 0; >+ ti->foreign_exception_state = __cxa_thread_info::none; >+ return; >+ } >Index: devel/libcxxrt/files/patch-test_CMakeLists.txt >=================================================================== >--- devel/libcxxrt/files/patch-test_CMakeLists.txt (nonexistent) >+++ devel/libcxxrt/files/patch-test_CMakeLists.txt (working copy) >@@ -0,0 +1,24 @@ >+--- test/CMakeLists.txt.orig 2013-12-26 03:11:27 UTC >++++ test/CMakeLists.txt >+@@ -23,6 +23,11 @@ add_executable(cxxrt-test-shared ${CXXTE >+ set_property(TARGET cxxrt-test-shared PROPERTY LINK_FLAGS -nodefaultlibs) >+ target_link_libraries(cxxrt-test-shared cxxrt-shared pthread dl c) >+ >++include_directories(${CMAKE_SOURCE_DIR}/src) >++add_executable(cxxrt-test-foreign-exceptions test_foreign_exceptions.cc) >++set_property(TARGET cxxrt-test-foreign-exceptions PROPERTY LINK_FLAGS "-nodefaultlibs -Wl,--wrap,_Unwind_RaiseException") >++target_link_libraries(cxxrt-test-foreign-exceptions cxxrt-static gcc_s pthread dl c) >++ >+ add_test(cxxrt-test-static-test >+ ${CMAKE_CURRENT_SOURCE_DIR}/run_test.sh >+ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-static >+@@ -35,6 +40,9 @@ add_test(cxxrt-test-shared-test >+ ${CMAKE_CURRENT_BINARY_DIR}/expected_output.log >+ ${CMAKE_CURRENT_BINARY_DIR}/test-shared-output.log) >+ >++add_test(cxxrt-test-foreign-exceptions >++ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/cxxrt-test-foreign-exceptions) >++ >+ set(valgrind "valgrind -q") >+ >+ if(TEST_VALGRIND) >Index: devel/libcxxrt/files/patch-test_test__foreign__exceptions.cc >=================================================================== >--- devel/libcxxrt/files/patch-test_test__foreign__exceptions.cc (nonexistent) >+++ devel/libcxxrt/files/patch-test_test__foreign__exceptions.cc (working copy) >@@ -0,0 +1,128 @@ >+--- test/test_foreign_exceptions.cc.orig 2016-05-29 13:30:15 UTC >++++ test/test_foreign_exceptions.cc >+@@ -0,0 +1,125 @@ >++#include <cstdio> >++#include <cstdlib> >++#include "unwind.h" >++ >++#define EXCEPTION_CLASS(a,b,c,d,e,f,g,h) \ >++ ((static_cast<uint64_t>(a) << 56) +\ >++ (static_cast<uint64_t>(b) << 48) +\ >++ (static_cast<uint64_t>(c) << 40) +\ >++ (static_cast<uint64_t>(d) << 32) +\ >++ (static_cast<uint64_t>(e) << 24) +\ >++ (static_cast<uint64_t>(f) << 16) +\ >++ (static_cast<uint64_t>(g) << 8) +\ >++ (static_cast<uint64_t>(h))) >++ >++// using ld --wrap=_Unwind_RaiseException hook feature >++extern "C" _Unwind_Reason_Code __real__Unwind_RaiseException (_Unwind_Exception *e); >++extern "C" _Unwind_Reason_Code __wrap__Unwind_RaiseException (_Unwind_Exception *e); >++ >++extern "C" _Unwind_Reason_Code __wrap__Unwind_RaiseException (_Unwind_Exception *e) >++{ >++ // clobber exception class forcing libcxx own exceptions to be treated >++ // as foreign exception within libcxx itself >++ e->exception_class = EXCEPTION_CLASS('F','O','R','E','I','G','N','\0'); >++ __real__Unwind_RaiseException(e); >++} >++ >++_Unwind_Exception global_e; >++ >++enum test_status { >++ PENDING, PASSED, FAILED >++}; >++ >++const char test_status_str[][8] = { >++ "PENDING", "PASSED", "FAILED" >++}; >++ >++test_status test1_status = PENDING; >++test_status test2_status = PENDING; >++test_status test3_status = PENDING; >++ >++void test2_exception_cleanup(_Unwind_Reason_Code code, _Unwind_Exception *e) >++{ >++ fputs("(2) exception_cleanup called\n", stderr); >++ if (e != &global_e) { >++ fprintf(stderr, "(2) ERROR: unexpected ptr: expecting %p, got %p\n", &global_e, e); >++ test2_status = FAILED; >++ } >++ if (test2_status == PENDING) >++ test2_status = PASSED; >++} >++ >++struct test3_exception >++{ >++ static int counter; >++ ~test3_exception() >++ { >++ counter++; >++ fputs("(3) exception dtor\n", stderr); >++ } >++}; >++int test3_exception::counter = 0; >++ >++int main() >++{ >++ /////////////////////////////////////////////////////////////// >++ fputs("(1) foreign exception, exception_cleanup=nullptr\n", stderr); >++ try >++ { >++ global_e.exception_class = 0; >++ global_e.exception_cleanup = 0; >++ __real__Unwind_RaiseException(&global_e); >++ } >++ catch (...) >++ { >++ } >++ test1_status = PASSED; >++ fputs("(1) PASS\n", stderr); >++ >++ /////////////////////////////////////////////////////////////// >++ fputs("(2) foreign exception, exception_cleanup present\n", stderr); >++ try >++ { >++ global_e.exception_class = 0; >++ global_e.exception_cleanup = test2_exception_cleanup; >++ __real__Unwind_RaiseException(&global_e); >++ } >++ catch (...) >++ { >++ } >++ fprintf(stderr, "(2) %s\n", test_status_str[test2_status]); >++ >++ /////////////////////////////////////////////////////////////// >++ fputs("(3) C++ exception in foreign environment\n", stderr); >++ int counter_expected; >++ try >++ { >++ // throw was rigged such that the runtime treats C++ exceptions >++ // as foreign ones >++ throw test3_exception(); >++ } >++ catch (test3_exception&) >++ { >++ fputs("(3) ERROR: wrong catch\n", stderr); >++ test3_status = FAILED; >++ } >++ catch (...) >++ { >++ fputs("(3) catch(...)\n", stderr); >++ counter_expected = test3_exception::counter + 1; >++ // one more dtor immediately after we leave catch >++ } >++ if (test3_status == PENDING && test3_exception::counter != counter_expected) { >++ fputs("(3) ERROR: exception dtor didn't run\n", stderr); >++ test3_status = FAILED; >++ } >++ if (test3_status == PENDING) >++ test3_status = PASSED; >++ fprintf(stderr, "(3) %s\n", test_status_str[test3_status]); >++ >++ /////////////////////////////////////////////////////////////// >++ if (test1_status == PASSED && test2_status == PASSED && test3_status == PASSED) >++ return EXIT_SUCCESS; >++ else >++ return EXIT_FAILURE; >++} >Index: devel/libcxxrt/pkg-descr >=================================================================== >--- devel/libcxxrt/pkg-descr (revision 416100) >+++ devel/libcxxrt/pkg-descr (working copy) >@@ -1,6 +1,6 @@ > This library implements the Code Sourcery C++ ABI, as documented here: > >-http://www.codesourcery.com/public/cxx-abi/abi.html >+WWW: http://www.codesourcery.com/public/cxx-abi/abi.html > > It is intended to sit below an STL implementation, and provide features required > by the compiler for implementation of the C++ language.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
mmokhi
:
maintainer-approval+
Actions:
View
|
Diff
Attachments on
bug 204786
:
163486
|
170805
|
170850