Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 07 Mar 2019 04:04:12 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 236344] [toolchain] gcc-built shared library crashes in static object constructors when dynamically loaded
Message-ID:  <bug-236344-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D236344

            Bug ID: 236344
           Summary: [toolchain] gcc-built shared library crashes in static
                    object constructors when dynamically loaded
           Product: Base System
           Version: 11.2-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: misc
          Assignee: bugs@FreeBSD.org
          Reporter: yuri@freebsd.org

Testcase: the port multimedia/webcamoid with added lines:
> WITH_DEBUG=3Dyes
> USE_GCC=3Dyes

When the executable runs, it crashes with this stack while the plugin is
dynamically loaded:
> Thread 1 received signal SIGSEGV, Segmentation fault.
> 0x00000008056fed78 in vtable for __cxxabiv1::__si_class_type_info () from=
 /lib/libcxxrt.so.1
> (gdb) bt
> #0  0x00000008056fed78 in vtable for __cxxabiv1::__si_class_type_info () =
at /lib/libcxxrt.so.1
> #1  0x00000008044ecf86 in __dynamic_cast () at /usr/local/lib/gcc8/libstd=
c++.so.6
> #2  0x000000080456bdb0 in bool std::has_facet<std::ctype<char> >(std::loc=
ale const&) () at /usr/local/lib/gcc8/libstdc++.so.6
> #3  0x000000080455f154 in std::basic_ios<char, std::char_traits<char> >::=
_M_cache_locale(std::locale const&) () at /usr/local/lib/gcc8/libstdc++.so.6
> #4  0x000000080455f5d0 in std::basic_ios<char, std::char_traits<char> >::=
init(std::basic_streambuf<char, std::char_traits<char> >*) ()
>     at /usr/local/lib/gcc8/libstdc++.so.6
> #5  0x0000000804500953 in std::ios_base::Init::Init() () at /usr/local/li=
b/gcc8/libstdc++.so.6
> #6  0x000000082aab4c56 in __static_initialization_and_destruction_0(int, =
int) (__initialize_p=3D1, __priority=3D65535) at /usr/local/lib/gcc8/includ=
e/c++/iostream:74
> #7  0x000000082aab4c89 in _GLOBAL__sub_I_ipcbridge.cpp(void) () at src/ip=
cbridge.cpp:3411
> #8  0x000000080073a7ab in objlist_call_init (list=3D<optimized out>, lock=
state=3D<optimized out>) at /usr/src/libexec/rtld-elf/rtld.c:2657
> #9  0x000000080073f009 in dlopen_object
>     (name=3D0x80087cc00 "z\270", <incomplete sequence \325>, fd=3D<optimi=
zed out>, refobj=3D<optimized out>, lo_flags=3D10, mode=3D1, lockstate=3D0x=
800000002)
>     at /usr/src/libexec/rtld-elf/rtld.c:3356
> #10 0x000000080073b836 in rtld_dlopen (name=3D0x80b364e98 "/usr/local/lib=
/avkys/libVirtualCamera.so", fd=3D-1, mode=3D<optimized out>) at /usr/src/l=
ibexec/rtld-elf/rtld.c:3231
> #11 0x000000080386a7e5 in  () at /usr/local/lib/qt5/libQt5Core.so.5
> #12 0x00000008038654ea in  () at /usr/local/lib/qt5/libQt5Core.so.5
> #13 0x0000000803865913 in  () at /usr/local/lib/qt5/libQt5Core.so.5
> #14 0x00000008009923b2 in AkElement::createPtr(QString const&, QString co=
nst&) (pluginId=3D..., elementName=3D...) at src/akelement.cpp:260
> #15 0x0000000800992311 in AkElement::create(QString const&, QString const=
&) (pluginId=3D..., elementName=3D...) at src/akelement.cpp:243
> #16 0x0000000000416753 in MediaTools::MediaTools(QObject*) (this=3D0x7fff=
ffffe780, parent=3D0x0) at src/mediatools.cpp:95
> #17 0x0000000000415c00 in main(int, char**) (argc=3D1, argv=3D0x7fffffffe=
808) at src/main.cpp:89
> (gdb)=20

The crash occurs during the initialization of this static object:
> 74	  static ios_base::Init __ioinit;

It calls std::ios_base::Init::Init() which has likely been called during the
main static constructors invocation, because it generally prints something =
from
the executable.
It looks like the constructor is called twice.
The same code works fine when built with clang.

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-236344-227>