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

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Mar 7 04:04:15 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=236344

            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 at FreeBSD.org
          Reporter: yuri at freebsd.org

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

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/libstdc++.so.6
> #2  0x000000080456bdb0 in bool std::has_facet<std::ctype<char> >(std::locale 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/lib/gcc8/libstdc++.so.6
> #6  0x000000082aab4c56 in __static_initialization_and_destruction_0(int, int) (__initialize_p=1, __priority=65535) at /usr/local/lib/gcc8/include/c++/iostream:74
> #7  0x000000082aab4c89 in _GLOBAL__sub_I_ipcbridge.cpp(void) () at src/ipcbridge.cpp:3411
> #8  0x000000080073a7ab in objlist_call_init (list=<optimized out>, lockstate=<optimized out>) at /usr/src/libexec/rtld-elf/rtld.c:2657
> #9  0x000000080073f009 in dlopen_object
>     (name=0x80087cc00 "z\270", <incomplete sequence \325>, fd=<optimized out>, refobj=<optimized out>, lo_flags=10, mode=1, lockstate=0x800000002)
>     at /usr/src/libexec/rtld-elf/rtld.c:3356
> #10 0x000000080073b836 in rtld_dlopen (name=0x80b364e98 "/usr/local/lib/avkys/libVirtualCamera.so", fd=-1, mode=<optimized out>) at /usr/src/libexec/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 const&) (pluginId=..., elementName=...) at src/akelement.cpp:260
> #15 0x0000000800992311 in AkElement::create(QString const&, QString const&) (pluginId=..., elementName=...) at src/akelement.cpp:243
> #16 0x0000000000416753 in MediaTools::MediaTools(QObject*) (this=0x7fffffffe780, parent=0x0) at src/mediatools.cpp:95
> #17 0x0000000000415c00 in main(int, char**) (argc=1, argv=0x7fffffffe808) at src/main.cpp:89
> (gdb) 

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.

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


More information about the freebsd-bugs mailing list