abi::__cxx_demangle appears to be broken on vanilla freebsd-13.0
Date: Fri, 06 May 2022 12:25:54 UTC
Hi, I am trying to add support for a C++ program which makes use of `abi::__cxx_demangle` for name unmangling. This worked well up to freebsd-12.2, but appears to be broken on a vanilla 13.0. Example: // foo.cc #include <cxxabi.h> #include <iostream> #include <typeinfo> int main() { const std::type_info &info = typeid(std::type_info); const char *name = info.name(); int status = 0; const char *dname = abi::__cxa_demangle(name, NULL, NULL, &status); if (status != 0) { std::cerr << "status=" << status << ' ' << name << '\n'; return 0; } std::cerr << name << ' ' << dname << '\n'; } This can be built with e.g., `make`: make foo If I run this on a vanilla freebsd-12.2 `__cxa_demangle` can demangle the name as mangled by the system: $ ./foo St9type_info std::type_info On vanilla freebsd-13.0 OTOH `__cxa_demangle` reports `status=-2` which according to https://panthema.net/2008/0901-stacktrace-demangled/cxa_demangle.html means: > -2: mangled_name is not a valid name under the C++ ABI mangling rules. I found a number of issues in bugzilla on broken unmangling in `c++filt` and mentions of workaround which went in to fix that, but on a vanilla 13.0 even `c++filt` seems unable to demangle `name`. I also found https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=222563 which seems to have staled for a long time (left a ping there). Could somebody point me to a way to fix this behavior? I cannot image that I am the only one having this issue. Cheers, Benjamin