Bug 204786 - devel/libcxxrt: crash when mixing different languages with exceptions (Affects databases/tarantool)
Summary: devel/libcxxrt: crash when mixing different languages with exceptions (Affect...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Rodrigo Osorio
URL: https://github.com/pathscale/libcxxrt...
Keywords: easy, patch, patch-ready
: 205582 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-11-24 15:56 UTC by Nick Zavaritsky
Modified: 2019-03-05 14:31 UTC (History)
4 users (show)

See Also:


Attachments
testcase (243 bytes, text/x-csrc)
2015-11-24 16:42 UTC, Nick Zavaritsky
no flags Details
patch brings upstream patch to fix it (with a little portlint fix) (7.89 KB, patch)
2016-05-29 17:45 UTC, Mahdi Mokhtari
mmokhi: maintainer-approval+
Details | Diff
previous patch with updating port revision (8.33 KB, patch)
2016-05-31 08:29 UTC, Mahdi Mokhtari
mmokhi: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Zavaritsky 2015-11-24 15:56:14 UTC
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.
Comment 1 Nick Zavaritsky 2015-11-24 16:42:19 UTC
Created attachment 163486 [details]
testcase
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2015-11-27 02:32:40 UTC
CC databases/tantool MAINTAINER
Comment 3 mejedi 2015-12-02 15:36:20 UTC
Upstream accepted a patch.

https://github.com/pathscale/libcxxrt/pull/32
Comment 4 Kubilay Kocak freebsd_committer freebsd_triage 2015-12-06 10:52:14 UTC
@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)
Comment 5 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-29 17:45:39 UTC
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
Comment 6 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-29 17:47:12 UTC
deassigning from myself so that a port-committer can take it and commit it :)
Comment 7 Rodrigo Osorio freebsd_committer freebsd_triage 2016-05-30 23:50:32 UTC
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
Comment 8 mejedi 2016-05-31 02:04:45 UTC
@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'.
Comment 9 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-31 08:29:43 UTC
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
Comment 10 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-31 08:33:22 UTC
(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
Comment 11 commit-hook freebsd_committer freebsd_triage 2016-05-31 20:08:23 UTC
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
Comment 12 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-31 20:13:24 UTC
(In reply to commit-hook from comment #11)
Thanks ;)
Comment 13 Rodrigo Osorio freebsd_committer freebsd_triage 2016-05-31 20:19:36 UTC
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.
Comment 14 Mahdi Mokhtari freebsd_committer freebsd_triage 2016-05-31 20:27:14 UTC
(In reply to Rodrigo Osorio from comment #13)
Yeah, sure i'll do :)
Thanks for pointing good points ;)
Comment 15 Rodrigo Osorio freebsd_committer freebsd_triage 2019-03-05 14:31:42 UTC
*** Bug 205582 has been marked as a duplicate of this bug. ***