The most recent update to libcxxrt (a7941b3326a38f203dab0b92a51e549499081a08) has broken demangling for basic types: This can be seen by the googletest/gmock_main/gmock-matchers_test:main test failing after that commit: For example i is not longer demangle to int and n no longer prints unsigned short: Expected: 1 fatal failure containing "Value of: n Expected: is > 10 Actual: 5 (of type unsigned short)" Actual: /local/scratch/alr48/cheri/freebsd/contrib/googletest/googlemock/test/gmock-matchers_test.cc:3179: Fatal failure: Value of: n Expected: is > 10 Actual: 5 (of type t) Expected: 1 non-fatal failure containing "Value of: 5 Expected: is > 5 Actual: 5 (of type int)" Actual: /local/scratch/alr48/cheri/freebsd/contrib/googletest/googlemock/test/gmock-matchers_test.cc:3233: Non-fatal failure: Value of: 5 Expected: is > 5 Actual: 5 (of type i)
Test program: #include <cxxabi.h> #include <stdio.h> #include <stdlib.h> #include <list> template <typename T> void test() { auto mangled = typeid(T).name(); printf("mangled='%s'\n", mangled); int status = 0; using abi::__cxa_demangle; auto demangled = __cxa_demangle(mangled, 0, 0, &status); printf("demangled='%s', status=%d\n", demangled, status); free(demangled); } int main() { test<int>(); test<char[4]>(); test<std::list<int>>(); test<char[4]>(); test<int>(); } libstdc++ output: root@freebsd-amd64:/ # g++ -nodefaultlibs test.cpp -lc++ -lc && ./a.out mangled='i' demangled='(null)', status=-2 mangled='A4_c' demangled='(null)', status=-2 mangled='NSt7__cxx114listIiSaIiEEE' demangled='(null)', status=-2 mangled='A4_c' demangled='(null)', status=-2 mangled='i' demangled='(null)', status=-2 root@freebsd-amd64:/# g++ -nodefaultlibs test.cpp -lstdc++ -lc && ./a.out mangled='i' demangled='int', status=0 mangled='A4_c' demangled='char [4]', status=0 mangled='NSt7__cxx114listIiSaIiEEE' demangled='std::__cxx11::list<int, std::allocator<int> >', status=0 mangled='A4_c' demangled='char [4]', status=0 mangled='i' demangled='int', status=0
Names such as "i" and "t" are no longer demangled because of the strlen(name) < 2 check here: https://github.com/freebsd/freebsd-src/blob/be2003ccfa1b12f372fa1329c38c29fe035f232f/contrib/libcxxrt/libelftc_dem_gnu3.c#L544 I'm not sure why the others aren't working anymore.
Aha, the other names are not demangled because of the following check: if (org[0] != '_' || org[1] != 'Z') return (NULL); That makes sense for functions, but not if you're trying to demangle types.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 commit 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 Merge: 04d2d2d7fd22 3f8a54b20893 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2021-02-18 21:30:27 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-02-18 21:30:27 +0000 Merge libcxxrt master 8049924686b8414d8e652cbd2a52c763b48e8456 Interesting fixes: b3c73ba libelftc_dem_gnu3: Sync with elftoolchain r3877 7b2335c Mostly fix __cxa_demangle after #3 Reported by: arichardson PR: 253226 MFC after: 3 days contrib/libcxxrt/libelftc_dem_gnu3.c | 14 +++++++++++--- contrib/libcxxrt/unwind-arm.h | 3 ++- contrib/libcxxrt/unwind-itanium.h | 10 +++++++--- 3 files changed, 20 insertions(+), 7 deletions(-)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d2b3fadf2db56131376a71b0597876b591a6aee4 commit d2b3fadf2db56131376a71b0597876b591a6aee4 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2021-02-19 18:18:22 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-02-19 21:18:02 +0000 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 contrib/libcxxrt/exception.cc | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=aeb00dca0d03e235c5aaabeef0ada9931d680a80 commit aeb00dca0d03e235c5aaabeef0ada9931d680a80 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2021-02-19 18:18:22 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-02-20 20:00:17 +0000 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 Differential Revision: https://reviews.freebsd.org/D28799 (cherry picked from commit d2b3fadf2db56131376a71b0597876b591a6aee4) contrib/libcxxrt/exception.cc | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-)
A commit in branch stable/12 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=9e86d16697654c58ae65fd13e2a35fc755ecf73a commit 9e86d16697654c58ae65fd13e2a35fc755ecf73a Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2021-02-19 18:18:22 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-02-20 20:00:55 +0000 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 Differential Revision: https://reviews.freebsd.org/D28799 (cherry picked from commit d2b3fadf2db56131376a71b0597876b591a6aee4) contrib/libcxxrt/exception.cc | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-)
A commit in branch stable/11 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=49e7d3fee6ac52d1c65160a71b1f2be70e43c5e1 commit 49e7d3fee6ac52d1c65160a71b1f2be70e43c5e1 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2021-02-19 18:18:22 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-02-20 20:01:49 +0000 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 Differential Revision: https://reviews.freebsd.org/D28799 (cherry picked from commit d2b3fadf2db56131376a71b0597876b591a6aee4) contrib/libcxxrt/exception.cc | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d4a0c102a237beb5650a2de4cc80f1aa496601d7 commit d4a0c102a237beb5650a2de4cc80f1aa496601d7 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2021-02-18 21:30:27 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-02-21 11:57:45 +0000 Merge libcxxrt master 8049924686b8414d8e652cbd2a52c763b48e8456 Interesting fixes: b3c73ba libelftc_dem_gnu3: Sync with elftoolchain r3877 7b2335c Mostly fix __cxa_demangle after #3 Reported by: arichardson PR: 253226 (cherry picked from commit 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368) 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 Differential Revision: https://reviews.freebsd.org/D28799 (cherry picked from commit d2b3fadf2db56131376a71b0597876b591a6aee4) contrib/libcxxrt/exception.cc | 30 ++++++------------------------ contrib/libcxxrt/libelftc_dem_gnu3.c | 14 +++++++++++--- contrib/libcxxrt/unwind-arm.h | 3 ++- contrib/libcxxrt/unwind-itanium.h | 10 +++++++--- 4 files changed, 26 insertions(+), 31 deletions(-)
A commit in branch stable/12 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=72b20d2aa973daa897256cdcf9c86d6f81f0e813 commit 72b20d2aa973daa897256cdcf9c86d6f81f0e813 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2021-02-18 21:30:27 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-02-21 11:59:13 +0000 Merge libcxxrt master 8049924686b8414d8e652cbd2a52c763b48e8456 Interesting fixes: b3c73ba libelftc_dem_gnu3: Sync with elftoolchain r3877 7b2335c Mostly fix __cxa_demangle after #3 Reported by: arichardson PR: 253226 (cherry picked from commit 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368) 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 Differential Revision: https://reviews.freebsd.org/D28799 (cherry picked from commit d2b3fadf2db56131376a71b0597876b591a6aee4) contrib/libcxxrt/exception.cc | 30 ++++++------------------------ contrib/libcxxrt/libelftc_dem_gnu3.c | 14 +++++++++++--- contrib/libcxxrt/unwind-arm.h | 3 ++- contrib/libcxxrt/unwind-itanium.h | 10 +++++++--- 4 files changed, 26 insertions(+), 31 deletions(-)
A commit in branch stable/11 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=0aa8c6552ff58a8945a62750771b3f582f938d08 commit 0aa8c6552ff58a8945a62750771b3f582f938d08 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2021-02-18 21:30:27 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-02-21 11:59:52 +0000 Merge libcxxrt master 8049924686b8414d8e652cbd2a52c763b48e8456 Interesting fixes: b3c73ba libelftc_dem_gnu3: Sync with elftoolchain r3877 7b2335c Mostly fix __cxa_demangle after #3 Reported by: arichardson PR: 253226 (cherry picked from commit 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368) 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 Differential Revision: https://reviews.freebsd.org/D28799 (cherry picked from commit d2b3fadf2db56131376a71b0597876b591a6aee4) contrib/libcxxrt/exception.cc | 30 ++++++------------------------ contrib/libcxxrt/libelftc_dem_gnu3.c | 14 +++++++++++--- contrib/libcxxrt/unwind-arm.h | 3 ++- contrib/libcxxrt/unwind-itanium.h | 10 +++++++--- 4 files changed, 26 insertions(+), 31 deletions(-)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d149877758f162f0c777e7760164bf2c1f7a1bc1 commit d149877758f162f0c777e7760164bf2c1f7a1bc1 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2021-02-22 20:01:09 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-02-22 20:01:09 +0000 Fix possibly unitialized variables in __cxa_demangle_gnu3() After 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 where I imported a more recent libcxxrt snapshot, the variables 'rtn' and 'has_ret' could in some cases be used while still uninitialized. Most obviously this would lead to a jemalloc complaint about a bad free(), aborting the program. Fix this by initializing a bunch variables in their declarations. This change has also been sent upstream, with some additional changes to be used in their testing framework. PR: 253226 MFC after: 3 days contrib/libcxxrt/libelftc_dem_gnu3.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=1c1460747efd44eb74762b960883656b56134e30 commit 1c1460747efd44eb74762b960883656b56134e30 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2021-02-22 20:01:09 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-02-24 19:39:15 +0000 Fix possibly unitialized variables in __cxa_demangle_gnu3() After 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 where I imported a more recent libcxxrt snapshot, the variables 'rtn' and 'has_ret' could in some cases be used while still uninitialized. Most obviously this would lead to a jemalloc complaint about a bad free(), aborting the program. Fix this by initializing a bunch variables in their declarations. This change has also been sent upstream, with some additional changes to be used in their testing framework. PR: 253226 (cherry picked from commit d149877758f162f0c777e7760164bf2c1f7a1bc1) contrib/libcxxrt/libelftc_dem_gnu3.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
A commit in branch stable/12 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=64809c763b0c73fe488b61601670067056b07780 commit 64809c763b0c73fe488b61601670067056b07780 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2021-02-22 20:01:09 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-02-24 19:39:57 +0000 Fix possibly unitialized variables in __cxa_demangle_gnu3() After 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 where I imported a more recent libcxxrt snapshot, the variables 'rtn' and 'has_ret' could in some cases be used while still uninitialized. Most obviously this would lead to a jemalloc complaint about a bad free(), aborting the program. Fix this by initializing a bunch variables in their declarations. This change has also been sent upstream, with some additional changes to be used in their testing framework. PR: 253226 (cherry picked from commit d149877758f162f0c777e7760164bf2c1f7a1bc1) contrib/libcxxrt/libelftc_dem_gnu3.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
A commit in branch stable/11 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=696961f67c5eaabe03713dbf1b4fc2b7a0ce1cb1 commit 696961f67c5eaabe03713dbf1b4fc2b7a0ce1cb1 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2021-02-22 20:01:09 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2021-02-24 19:40:13 +0000 Fix possibly unitialized variables in __cxa_demangle_gnu3() After 0ee0dbfb0d26cf4bc37f24f12e76c7f532b0f368 where I imported a more recent libcxxrt snapshot, the variables 'rtn' and 'has_ret' could in some cases be used while still uninitialized. Most obviously this would lead to a jemalloc complaint about a bad free(), aborting the program. Fix this by initializing a bunch variables in their declarations. This change has also been sent upstream, with some additional changes to be used in their testing framework. PR: 253226 (cherry picked from commit d149877758f162f0c777e7760164bf2c1f7a1bc1) contrib/libcxxrt/libelftc_dem_gnu3.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
^Triage: committed and MFCed back in 2021.