[Bug 236344] [toolchain] gcc-built shared library crashes in static object constructors when dynamically loaded

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 12 Oct 2021 08:56:05 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236344

David Chisnall <theraven@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |theraven@FreeBSD.org

--- Comment #9 from David Chisnall <theraven@FreeBSD.org> ---
From the stack trace, it looks as if this is linking both from the base system
libcxxrt.so and libstdc++.so from the gcc8 port.  The version of libstdc++.so
from the base system was modified to link libcxxrt.so but I believe the
versions from ports embed libsupc++.a.  Both libcxxrt and libsupc++ define the
same symbols and so you end up with a mixture of them being called.  In
particular, you're mixing part of the `dynamic_cast` implementation from
libsupc++ (frame #1) with part from libcxxrt (frame #0).  This is very unlikely
to work.

The correct fix for this would be to make the GCC ports link libstdc++.so
against libcxxrt.so instead of building libsupc++.a, but that probably requires
some invasive changes to the build system.

In general, mixing code linked against libc++ and libstdc++ is unlikely to
work.  There are three ways of fixing this:

 - Teach the libstdc++ build to use libcxxrt
 - Teach gcc to support -stdlib=libc++
 - Use something like `-nostdinc++ -nodefaultlibs -isystem
<install>/include/c++/v1    -lc++ -lcxxrt -lm -lc -lgcc_s -lgcc` when compiling
/ linking C++ things with gcc.

-- 
You are receiving this mail because:
You are the assignee for the bug.