Unwind API was specifically designed to allow mixed language environments where exceptions from different runtimes interoperate. One particular example is C++/LuaJit combination. Due to the issues in libcxxrt, databases/tarantool crashes when linked against libcxxrt. __cxa_free_exception does the math wrong when converting from _Unwind_Exception* to __cxx_exception*. _Unwind_Exception instance is actually enclosed within __cxx_exception structure, the last member. The resulting pointer is off by -32 bytes. Leads to a crash in _Unwind_DeleteException when LuaJIT is releasing a C++ exception.
Created attachment 163486 [details] testcase
CC databases/tantool MAINTAINER
Upstream accepted a patch. https://github.com/pathscale/libcxxrt/pull/32
@Nick, this port doesn't currently have a maintainer, could you provide a patch against the port head and provide confirmation that the change passes QA? (portlint, poudriere)
Created attachment 170805 [details] patch brings upstream patch to fix it (with a little portlint fix) QA: done Portlint Okay (no error nor warning) Poudriere Okay
deassigning from myself so that a port-committer can take it and commit it :)
I just quick check, the patch looks ok, the revision number will be updated. @nick: I didn't see libcxxrt as a dependency for databases/tarantool
@Rodrigo: I assume that any program written in C++ and built with clang depends on libcxxrt. However, there are actually 2 instances of libcxxrt in FreeBSD - this port AND another one being the part of the 'core system'.
Created attachment 170850 [details] previous patch with updating port revision @Rodrigo Thanks for pointing about revision (i forgot that :D) This new patch fixes that too :) QA: done Portlint Okay Poudriere Okay
(In reply to mejedi from comment #8) Should that (base libcxxrt) be patched too ? however, i think this one (port's libcxxrt) and base's one are independent
A commit references this bug: Author: rodrigo Date: Tue May 31 20:07:22 UTC 2016 New revision: 416217 URL: https://svnweb.freebsd.org/changeset/ports/416217 Log: Fix crash when libcxxrt exceptions been freed by a different language runtime, and when libcxxrt itself free foreign exceptions. Unwind API was specifically designed to allow mixed language environments where exceptions from different runtimes interoperate. One particular example is C++/LuaJit combination. Due to the issues in libcxxrt, databases/tarantool crashes when linked against libcxxrt. The issue was merged by upstream butat the moment not officially released. https://github.com/pathscale/libcxxrt/pull/32 PR: 204786 Submitted by: Nick Zavaritsky <mejedi@gmail.com> Approved by: Mahdi Mokhtari <mokhi64@gmail.com> (maintainer) Changes: head/devel/libcxxrt/Makefile head/devel/libcxxrt/files/ head/devel/libcxxrt/files/patch-src_exception.cc head/devel/libcxxrt/files/patch-test_CMakeLists.txt head/devel/libcxxrt/files/patch-test_test__foreign__exceptions.cc head/devel/libcxxrt/pkg-descr
(In reply to commit-hook from comment #11) Thanks ;)
Committed with minor changes, thanks. Fixing the port let peoples finding issues with base version move to a more recent version. BTW the person who merges the patch upstream is a FreeBSD src developer, you can ask him about that. You can also open a bug requesting a sync of libcxxrt in base with upstream for the next release.
(In reply to Rodrigo Osorio from comment #13) Yeah, sure i'll do :) Thanks for pointing good points ;)
*** Bug 205582 has been marked as a duplicate of this bug. ***