History log of /freebsd-current/contrib/libcxxrt/exception.cc
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 3fb2e045 26-Jan-2024 Dimitry Andric <dim@FreeBSD.org>

Tentatively apply https://github.com/libcxxrt/libcxxrt/pull/27

This marks __cxa_allocate_exception, __cxa_free_exception and
__cxa_init_primary_exception noexcept, to ensure compatibility with
libc++'s declarations.

PR: 276104
MFC after: 1 month


# ecf41062 25-Jan-2024 Dimitry Andric <dim@FreeBSD.org>

Merge libcxxrt master 03c83f5a57be8c5b1a29a68de5638744f17d28ba

Interesting fixes (* were already cherry-picked):
- 03c83f5 add __cxa_init_primary_exception (#23)
* 5d8a158 Fix two bugs in __cxa_end_cleanup()
* b00c6c5 Insert padding in __cxa_dependent_exception
* 45ca8b1 Insert padding in __cxa_exception struct for compatibility
* f2e5509 Fix unlock in two-word version and add missing comment.
- 6229590 Add an option for disabling emergency buffers. (#14)

MFC after: 2 weeks


# cbd1e831 07-Aug-2022 Mark Johnston <markj@FreeBSD.org>

Merge libcxxrt commit 5d8a15823a103bbc27f1bfdcf2b5aa008fab57dd

Fix two bugs in __cxa_end_cleanup()

Per the EHABI32 specification, __cxa_end_cleanup must take care to
preserve registers before calling _Unwind_Resume(). So, libcxxrt uses
an assembly stub which preserves caller-saved registers around the call
to __cxa_get_cleanup(). But:
- it failed to restore them properly,
- it did not preserve the link register.

Fix both of these problems. This is needed to fix exception unwinding
on FreeBSD with LLVM 14. Note that r4 is callee-saved but is pushed
onto the stack to preserve stack pointer alignment.

Sponsored-by: The FreeBSD Foundation

MFC after: 1 week

# c40e4349 27-Apr-2022 Ed Maste <emaste@FreeBSD.org>

libcxxrt: Insert padding in __cxa_dependent_exception

Padding was added to __cxa_exception in 45ca8b19 and
__cxa_dependent_exception needs the same layout.
Add some static_asserts to detect this in the future.

Merge of libcxxrt commit b00c6c564357

# bfffb66e 20-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Reapply libcxxrt atomics cleanup commit, preparing for upstream fix

This reapplies upstream commit fd484be, as there is a follow-up fix for
the possible hangs in __cxa_guard_acquire() on i386:

Atomics cleanup (#11)

We need to test exception specifiers but they're gone in C++17 so
compile the tests with an older version of the standard.

Rewrite the guard logic to be more idiomatic C++ and more
comprehensible and make sure that atomics are used where necessary.

Obtained from: https://github.com/libcxxrt/libcxxrt/commit/fd484be
Fixes: 56aaed388b0a
MFC after: 2 weeks

# 25482379 19-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Revert upstream libcxxrt commit which can cause hangs on i386

This reverts upstream commit fd484be:

Atomics cleanup (#11)

We need to test exception specifiers but they're gone in C++17 so
compile the tests with an older version of the standard.

Rewrite the guard logic to be more idiomatic C++ and more
comprehensible and make sure that atomics are used where necessary.

It looks like there are some corner cases in the i386 and/or 32-bit
atomics handling, which can make __cxa_guard_acquire() hang in certain
situations.

Reported by: antoine
Obtained from: https://github.com/libcxxrt/libcxxrt/commit/fd484be
Fixes: 56aaed388b0a
MFC after: 2 weeks

# 56aaed38 09-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Merge libcxxrt master fd484be8d1e94a1fcf6bc5c67e5c07b65ada19b6

Interesting fixes:
47661d0 Match libc++abi/libsupc++ when demangling array types
e44a05c Fix unitialized variable in __cxa_demangle_gnu3 after #6 (#8)
5088b05 Remove some code duplication.
fd484be Atomics cleanup (#11)

MFC after: 2 weeks


# 72df847a 08-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Remove compat hacks from libcxxrt's _Unwind_Exception

This reverts 9097e3cbcac4, which was in itself a revert of upstream
libcxxrt commits 88bdf6b290da ("Specify double-word alignment for ARM
unwind") and b96169641f79 ("Updated Itanium unwind"), and a
reapplication of our commit 3c4fd2463bb2 ("libcxxrt: add padding in
__cxa_allocate_* to fix alignment").

The editors/libreoffice port will be patched to be able to cope with the
standards-compliant alignment of _Unwind_Exception and consequently,
that of __cxa_exception. The layouts and sizes of these structures
should then be completely the same for libcxxrt, libunwind and
libc++abi.

PR: 262008
Reviewed by: emaste, jhb, theraven
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D34488

# 9097e3cb 13-Mar-2021 Dimitry Andric <dim@FreeBSD.org>

Partially revert libcxxrt changes to avoid _Unwind_Exception change

(Note I am also applying this to main and stable/13, to restore the old
libcxxrt ABI and to avoid having to maintain a compat library.)

After the recent cherry-picking of libcxxrt commits 0ee0dbfb0d26 and
d2b3fadf2db5, users reported that editors/libreoffice packages from the
official package builders did not start anymore. It turns out that the
combination of these commits subtly changes the ABI, requiring all
applications that depend on internal details of struct _Unwind_Exception
(available via unwind-arm.h and unwind-itanium.h) to be recompiled.

However, the FreeBSD package builders always use -RELEASE jails, so
these still use the old declaration of struct _Unwind_Exception, which
is not entirely compatible. In particular, LibreOffice uses this struct
in its internal "uno bridge" component, where it attempts to setup its
own exception handling mechanism.

To fix this incompatibility, go back to the old declarations of struct
_Unwind_Exception, and restore the __LP64__ specific workaround we had
in place before (which was to cope with yet another, older ABI bug).

Effectively, this reverts upstream libcxxrt commits 88bdf6b290da
("Specify double-word alignment for ARM unwind") and b96169641f79
("Updated Itanium unwind"), and reapplies our commit 3c4fd2463bb2
("libcxxrt: add padding in __cxa_allocate_* to fix alignment").

PR: 253840

# d2b3fadf 19-Feb-2021 Dimitry Andric <dim@FreeBSD.org>

Revert 3c4fd2463bb2 since upstream libcxxrt fixed it in another way

In 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 I imported a more recent
libcxxrt snapshot, which includes an upstream fix for the padding of
struct _Unwind_Exception:

https://github.com/libcxxrt/libcxxrt/commit/e458560b7e22fff59af643dba363544b393bd8db

However, we also had a similar fix in our tree as:
https://cgit.freebsd.org/src/commit/?id=3c4fd2463bb29f65ef1404011fcb31e508cdf2e2

Since having both fixes makes the struct too large again, it leads to
SIGBUSes when throwing exceptions on amd64 (or other LP64 arches). This
is most easily tested by running kyua without any arguments.

It looks like our fix is no longer needed now, so revert it to reduce
diffs against upstream.

PR: 253226
Reviewed by: arichardson, kp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D28799

# e91d723a 26-Jul-2019 Dimitry Andric <dim@FreeBSD.org>

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


# 3c4fd246 21-Jul-2016 Ed Maste <emaste@FreeBSD.org>

libcxxrt: add padding in __cxa_allocate_* to fix alignment

The addition of the referenceCount to __cxa_allocate_exception put the
unwindHeader at offset 0x58 in __cxa_exception, but it requires 16-byte
alignment. In order to avoid changing the current __cxa_exception ABI
(and thus breaking its consumers), add explicit padding in the
allocation routines (and account for it when freeing).

This is intended as a lower-risk change for FreeBSD 11. A "more correct"
fix should be prepared for upstream and -CURRENT.

Reviewed by: dim
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D7271

# 076e75eb 05-May-2016 Dimitry Andric <dim@FreeBSD.org>

Import libcxxrt master 516a65c109eb0a01e5e95fbef455eb3215135cef.

Interesting fixes:
3adaa2e Fix _Unwind_Exception cleanup functions
286776c Check exception cleanup function ptr before calling
edda626 Correct exception specifications on new and delete operators


# bb52ed32 05-Oct-2015 Dimitry Andric <dim@FreeBSD.org>

Add std::uncaught_exceptions() to libcxxrt (C++17, see N4152 and N4259).
This has also been submitted upstream.

# 76ad5667 25-Sep-2015 Conrad Meyer <cem@FreeBSD.org>

MFV c3ccd112: Correct off-by-ones in free_exception of emergency buffer

Note, this has been broken since import in r227825.

PR: https://github.com/pathscale/libcxxrt/issues/29
Reviewed by: emaste (earlier version), kan (informally)
Obtained from: Anton Rang
Relnotes: yes
Sponsored by: EMC / Isilon Storage Division
Differential Revision: https://reviews.freebsd.org/D3733

# 07122a2a 31-Jan-2015 Dimitry Andric <dim@FreeBSD.org>

Import libcxxrt master 1cb607e89f6135bbc10f3d3b6fba1f983e258dcc.

Interesting fixes:
1cb607e Correct gcc version check for __cxa_begin_catch() declaration
with or without throw()

MFC after: 3 days


# f2dc4184 30-Dec-2014 Dimitry Andric <dim@FreeBSD.org>

Import libcxxrt master 00bc29eb6513624824a6d7db2ebc768a4216a604.

Interesting fixes:
76584a0 Reorganize code to use only 32bit atomic ops for 32bit platforms
30d2ae5 Implement __cxa_throw_bad_array_new_length

Reviewed by: bapt
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D1390


# 26b8b75c 31-Aug-2013 David Chisnall <theraven@FreeBSD.org>

Don't use _Unwind_Backtrace() on ARM as it's currently missing from our libgcc_s. andrew@ has patches to add it, so this can be reverted and sync'd with upstream later.

# 4bab9fd9 10-Jul-2013 David Chisnall <theraven@FreeBSD.org>

Import new libcxxrt / libc++. This brings some bug fixes, including a potential race condition for static initialisers.


# d9e22925 27-Apr-2013 Dimitry Andric <dim@FreeBSD.org>

Merge libcxxrt c812a07cd2f95c1403baf0bbe0366e7618d1d6d3:

* Don't call the _fast version of the TLS accessor in terminate() or
unexpected().
1) TLS may not have been set up yet.
2) When we're in one of these functions, Really Bad Stuff has
happened and potentially saving a few cycles really isn't
important.
* Merge in fixes from FreeBSD trunk to make atomics work with recent
clang.

MFC after: 1 week


# fe9b3289 07-Feb-2013 David Chisnall <theraven@FreeBSD.org>

Fix a copy-and-paste error in libcxxrt.

# d5861eaa 21-Jan-2013 David Chisnall <theraven@FreeBSD.org>

Import new fix from libcxxrt. This fixes the case where you attempt to rethrow
an exception when you haven't caught one. This is largely a cosmetic fix, as
(unless you have a very unusual terminate handler installed) it will print a
nice error and then abort, rather than just aborting.

MFC after: 7 days


# f7cb1657 11-Jan-2013 David Chisnall <theraven@FreeBSD.org>

Merge new version of libcxxrt. This brings in three fixes:

- Don't treat pointers to members as pointers in catch blocks (they're usually
fat pointers).

- Correctly catch foreign exceptions in catchalls.

- Ensure that a happens-before relationship is established when setting
terminate handlers in one thread and calling them in another.


# c725650d 20-Mar-2012 David Chisnall <theraven@FreeBSD.org>

Import new version of libcxxrt. Now works correctly with libobjc2 to implement
the unified exception model for Objective-C++.

Approved by: dim (mentor)


# 94e3ee44 13-Mar-2012 David Chisnall <theraven@FreeBSD.org>

Import new versions of libcxxrt and libc++.
Please tests any C++ code you care about with -stdlib=libc++!

Approved by: dim (mentor)


# db47c4bf 26-Nov-2011 David Chisnall <theraven@FreeBSD.org>

Update libcxxrt to remove the pthread dependency.

Also add the license from upstream to contrib.

Approved by: dim (mentor)


# 7a984708 25-Nov-2011 David Chisnall <theraven@FreeBSD.org>

Import libc++ / libcxxrt into base. Not build by default yet (use
MK_LIBCPLUSPLUS=yes to enable). This is a work-in-progress. It works for
me, but is not guaranteed to work for anyone else and may eat your dog.

To build C++ using libc++, add -stdlib=libc++ to your CXX and LD flags.

Bug reports welcome, bug fixes even more welcome...

Approved by: dim (mentor)


# cbd1e831 07-Aug-2022 Mark Johnston <markj@FreeBSD.org>

Merge libcxxrt commit 5d8a15823a103bbc27f1bfdcf2b5aa008fab57dd

Fix two bugs in __cxa_end_cleanup()

Per the EHABI32 specification, __cxa_end_cleanup must take care to
preserve registers before calling _Unwind_Resume(). So, libcxxrt uses
an assembly stub which preserves caller-saved registers around the call
to __cxa_get_cleanup(). But:
- it failed to restore them properly,
- it did not preserve the link register.

Fix both of these problems. This is needed to fix exception unwinding
on FreeBSD with LLVM 14. Note that r4 is callee-saved but is pushed
onto the stack to preserve stack pointer alignment.

Sponsored-by: The FreeBSD Foundation

MFC after: 1 week


# c40e4349 27-Apr-2022 Ed Maste <emaste@FreeBSD.org>

libcxxrt: Insert padding in __cxa_dependent_exception

Padding was added to __cxa_exception in 45ca8b19 and
__cxa_dependent_exception needs the same layout.
Add some static_asserts to detect this in the future.

Merge of libcxxrt commit b00c6c564357


# bfffb66e 20-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Reapply libcxxrt atomics cleanup commit, preparing for upstream fix

This reapplies upstream commit fd484be, as there is a follow-up fix for
the possible hangs in __cxa_guard_acquire() on i386:

Atomics cleanup (#11)

We need to test exception specifiers but they're gone in C++17 so
compile the tests with an older version of the standard.

Rewrite the guard logic to be more idiomatic C++ and more
comprehensible and make sure that atomics are used where necessary.

Obtained from: https://github.com/libcxxrt/libcxxrt/commit/fd484be
Fixes: 56aaed388b0a
MFC after: 2 weeks


# 25482379 19-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Revert upstream libcxxrt commit which can cause hangs on i386

This reverts upstream commit fd484be:

Atomics cleanup (#11)

We need to test exception specifiers but they're gone in C++17 so
compile the tests with an older version of the standard.

Rewrite the guard logic to be more idiomatic C++ and more
comprehensible and make sure that atomics are used where necessary.

It looks like there are some corner cases in the i386 and/or 32-bit
atomics handling, which can make __cxa_guard_acquire() hang in certain
situations.

Reported by: antoine
Obtained from: https://github.com/libcxxrt/libcxxrt/commit/fd484be
Fixes: 56aaed388b0a
MFC after: 2 weeks


# 72df847a 08-Mar-2022 Dimitry Andric <dim@FreeBSD.org>

Remove compat hacks from libcxxrt's _Unwind_Exception

This reverts 9097e3cbcac4, which was in itself a revert of upstream
libcxxrt commits 88bdf6b290da ("Specify double-word alignment for ARM
unwind") and b96169641f79 ("Updated Itanium unwind"), and a
reapplication of our commit 3c4fd2463bb2 ("libcxxrt: add padding in
__cxa_allocate_* to fix alignment").

The editors/libreoffice port will be patched to be able to cope with the
standards-compliant alignment of _Unwind_Exception and consequently,
that of __cxa_exception. The layouts and sizes of these structures
should then be completely the same for libcxxrt, libunwind and
libc++abi.

PR: 262008
Reviewed by: emaste, jhb, theraven
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D34488


# 9097e3cb 13-Mar-2021 Dimitry Andric <dim@FreeBSD.org>

Partially revert libcxxrt changes to avoid _Unwind_Exception change

(Note I am also applying this to main and stable/13, to restore the old
libcxxrt ABI and to avoid having to maintain a compat library.)

After the recent cherry-picking of libcxxrt commits 0ee0dbfb0d26 and
d2b3fadf2db5, users reported that editors/libreoffice packages from the
official package builders did not start anymore. It turns out that the
combination of these commits subtly changes the ABI, requiring all
applications that depend on internal details of struct _Unwind_Exception
(available via unwind-arm.h and unwind-itanium.h) to be recompiled.

However, the FreeBSD package builders always use -RELEASE jails, so
these still use the old declaration of struct _Unwind_Exception, which
is not entirely compatible. In particular, LibreOffice uses this struct
in its internal "uno bridge" component, where it attempts to setup its
own exception handling mechanism.

To fix this incompatibility, go back to the old declarations of struct
_Unwind_Exception, and restore the __LP64__ specific workaround we had
in place before (which was to cope with yet another, older ABI bug).

Effectively, this reverts upstream libcxxrt commits 88bdf6b290da
("Specify double-word alignment for ARM unwind") and b96169641f79
("Updated Itanium unwind"), and reapplies our commit 3c4fd2463bb2
("libcxxrt: add padding in __cxa_allocate_* to fix alignment").

PR: 253840


# d2b3fadf 19-Feb-2021 Dimitry Andric <dim@FreeBSD.org>

Revert 3c4fd2463bb2 since upstream libcxxrt fixed it in another way

In 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 I imported a more recent
libcxxrt snapshot, which includes an upstream fix for the padding of
struct _Unwind_Exception:

https://github.com/libcxxrt/libcxxrt/commit/e458560b7e22fff59af643dba363544b393bd8db

However, we also had a similar fix in our tree as:
https://cgit.freebsd.org/src/commit/?id=3c4fd2463bb29f65ef1404011fcb31e508cdf2e2

Since having both fixes makes the struct too large again, it leads to
SIGBUSes when throwing exceptions on amd64 (or other LP64 arches). This
is most easily tested by running kyua without any arguments.

It looks like our fix is no longer needed now, so revert it to reduce
diffs against upstream.

PR: 253226
Reviewed by: arichardson, kp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D28799


# 3c4fd246 21-Jul-2016 Ed Maste <emaste@FreeBSD.org>

libcxxrt: add padding in __cxa_allocate_* to fix alignment

The addition of the referenceCount to __cxa_allocate_exception put the
unwindHeader at offset 0x58 in __cxa_exception, but it requires 16-byte
alignment. In order to avoid changing the current __cxa_exception ABI
(and thus breaking its consumers), add explicit padding in the
allocation routines (and account for it when freeing).

This is intended as a lower-risk change for FreeBSD 11. A "more correct"
fix should be prepared for upstream and -CURRENT.

Reviewed by: dim
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D7271


# bb52ed32 05-Oct-2015 Dimitry Andric <dim@FreeBSD.org>

Add std::uncaught_exceptions() to libcxxrt (C++17, see N4152 and N4259).
This has also been submitted upstream.


# 76ad5667 25-Sep-2015 Conrad Meyer <cem@FreeBSD.org>

MFV c3ccd112: Correct off-by-ones in free_exception of emergency buffer

Note, this has been broken since import in r227825.

PR: https://github.com/pathscale/libcxxrt/issues/29
Reviewed by: emaste (earlier version), kan (informally)
Obtained from: Anton Rang
Relnotes: yes
Sponsored by: EMC / Isilon Storage Division
Differential Revision: https://reviews.freebsd.org/D3733


# 26b8b75c 31-Aug-2013 David Chisnall <theraven@FreeBSD.org>

Don't use _Unwind_Backtrace() on ARM as it's currently missing from our libgcc_s. andrew@ has patches to add it, so this can be reverted and sync'd with upstream later.


# fe9b3289 07-Feb-2013 David Chisnall <theraven@FreeBSD.org>

Fix a copy-and-paste error in libcxxrt.