Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 May 2022 14:25:54 +0200
From:      Benjamin Bannier <benjamin.bannier@corelight.com>
To:        freebsd-hackers@freebsd.org
Subject:   abi::__cxx_demangle appears to be broken on vanilla freebsd-13.0
Message-ID:  <B01BAE5D-15B6-496D-91EA-2529EF988B79@corelight.com>

next in thread | raw e-mail | index | archive | help
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 =3D typeid(std::type_info);

         const char *name =3D info.name();
         int status =3D 0;

         const char *dname =3D abi::__cxa_demangle(name, NULL, NULL, =
&status);

         if (status !=3D 0) {
           std::cerr << "status=3D" << 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=3D-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=3D222563 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=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B01BAE5D-15B6-496D-91EA-2529EF988B79>