Created attachment 239651 [details] testcase.cpp The attached program compiles with: > g++12 -g -std=c++20 testcase.cpp -ltbb but the resulting executabls SEGVs. FreeBSD 13.1 STABLE
Bug confirmed, I can reproduce the issue. I will study the problem as soon as possible.
If none of devel/onetbb and devel/tbb are installed, I can compile the test case successfully with > g++12 -g -std=c++20 testcase.cpp And the compiled binary runs without any segmentation fault. On the other hand, if any of devel/onetbb and devel/tbb is installed, then -ltbb is necessary for a successful build and then the binary gets a segmentaion fault. I CC the maintainer of devel/onetbb and devel/tbb, which might be able to help.
Hello, Thanks Lorenzo. I am currently AFK, I'll see if I can help ASAP. Cheers, Ganaelk.
Hello, First of all, Gcc detects the presence of Intel TBB headers, this is why -ltbb is needed to build your program when OneTbb port is installed, see: /usr/local/lib/gcc12/include/c++/x86_64-portbld-freebsd13.1/bits/c++config.h: 827 // For now this defaults to being based on the presence of Thread Building Blocks 828 # ifndef _GLIBCXX_USE_TBB_PAR_BACKEND 829 # define _GLIBCXX_USE_TBB_PAR_BACKEND __has_include(<tbb/tbb.h>) 830 # endif 831 // This section will need some rework when a new (default) backend type is added 832 # if _GLIBCXX_USE_TBB_PAR_BACKEND 833 # define _PSTL_PAR_BACKEND_TBB 834 # else 835 # define _PSTL_PAR_BACKEND_SERIAL 836 # endif I could reproduce your problem and got a backtrace: (gdb) bt #0 0x000000080122cd48 in vtable for __cxxabiv1::__si_class_type_info () from /lib/libcxxrt.so.1 #1 0x00000008008a6263 in __dynamic_cast () from /usr/local/lib/gcc12/libstdc++.so.6 #2 0x0000000800932585 in bool std::has_facet<std::ctype<char> >(std::locale const&) () from /usr/local/lib/gcc12/libstdc++.so.6 #3 0x00000008009244e5 in std::basic_ios<char, std::char_traits<char> >::_M_cache_locale(std::locale const&) () from /usr/local/lib/gcc12/libstdc++.so.6 #4 0x0000000800924641 in std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*) () from /usr/local/lib/gcc12/libstdc++.so.6 #5 0x00000008008baad6 in std::ios_base::Init::Init() () from /usr/local/lib/gcc12/libstdc++.so.6 #6 0x0000000000403449 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at /usr/local/lib/gcc12/include/c++/iostream:74 #7 0x0000000000404087 in _GLOBAL__sub_I_main () at testcase.cpp:23 #8 0x00000008006160fd in ?? () from /libexec/ld-elf.so.1 #9 0x0000000000000000 in ?? () It seems to be related to PR#236344 and triggered when mixing libstdc++/libsupc++ from Gcc (frame #1) and libc++/libcxxrt from base (frame #0). Re-building your test program that way : $ g++12 -g -std=c++20 -lc++ -lcxxrt -ltbb testcase.cpp seems to fix the problem. Cheers, Ganael.
Thanks Ganael. Then I close this bug report as a duplicate of bug report #236344. I will also track bug report #236344, in case I might be able to help. *** This bug has been marked as a duplicate of bug 236344 ***
(In reply to Ganael LAPLANCHE from comment #4) Another thing to try with g++12 instead of -lc++ -lcxxrt is -stdlib=libc++ . That should automatically deal with those and possibly other related references tied to libc++ use. It is something that was enabled in some lang/gcc* ports back in late 2022-Aug.
(In reply to Mark Millard from comment #6) Thanks for the hint, Mark!