From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A8EFB3858C60; Wed, 9 Mar 2022 04:13:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A8EFB3858C60 From: "lightningdzeyenr at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/104852] New: std::[j]thread::detach() still gives segmentation faults with glibc 2.34 Date: Wed, 09 Mar 2022 04:13:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lightningdzeyenr at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Mar 2022 04:13:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104852 Bug ID: 104852 Summary: std::[j]thread::detach() still gives segmentation faults with glibc 2.34 Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: lightningdzeyenr at gmail dot com Target Milestone: --- I'm using g++ 11.2.0 on Ubuntu 21.10 (Pop!_OS 21.10) and trying to compile a project that uses the std::[j]thread::detach() function a lot. When I statically link it, I always get a segmentation fault for what seems to be something in the libpthread library. This happens with both std::thread and std::jthread. ldd --version shows a glibc version of 2.34 (specifically 2.34-0ubuntu3.2), and ld --version shows 2.37, both versions at which this = bug should have been fixed. Here's the output of g++ -v: Using built-in specs. COLLECT_GCC=3Dg++ COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper OFFLOAD_TARGET_NAMES=3Dnvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=3D1 Target: x86_64-linux-gnu [I'm using AMD Zen 3] Configured with: ../src/configure -v --with-pkgversion=3D'Ubuntu 11.2.0-7ub= untu2' --with-bugurl=3Dfile:///usr/share/doc/gcc-11/README.Bugs --enable-languages=3Dc,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix= =3D/usr --with-gcc-major-version-only --program-suffix=3D-11 --program-prefix=3Dx86_64-linux-gnu- --enable-shared --enable-linker-build-= id --libexecdir=3D/usr/lib --without-included-gettext --enable-threads=3Dposix --libdir=3D/usr/lib --enable-nls --enable-bootstrap --enable-clocale=3Dgnu --enable-libstdcxx-debug --enable-libstdcxx-time=3Dyes --with-default-libstdcxx-abi=3Dnew --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-= zlib --enable-libphobos-checking=3Drelease --with-target-system-zlib=3Dauto --enable-objc-gc=3Dauto --enable-multiarch --disable-werror --enable-cet --with-arch-32=3Di686 --with-abi=3Dm64 --with-multilib-list=3Dm32,m64,mx32 --enable-multilib --with-tune=3Dgeneric --enable-offload-targets=3Dnvptx-none=3D/build/gcc-11-ZPT0kp/gcc-11-11.2.0/= debian/tmp-nvptx/usr,amdgcn-amdhsa=3D/build/gcc-11-ZPT0kp/gcc-11-11.2.0/deb= ian/tmp-gcn/usr --without-cuda-driver --enable-checking=3Drelease --build=3Dx86_64-linux-gnu --host=3Dx86_64-linux-gnu --target=3Dx86_64-linux-gnu --with-build-config=3Dbootstrap-lto-lean --enable-link-serialization=3D2 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.2.0 (Ubuntu 11.2.0-7ubuntu2) I'm compiling with the CMake command=20 > cmake source -DADD_FLAGS=3D"-static -lpthread" which adds these flags to the end of CMAKE_CXX_FLAGS, and > cmake --build . -j 12 to build. I can't provide the .i files because even compressed as a .tar.gz, the arch= ive is too big (4.5MB). However, this is reproducible by cloning the repo=20 (https://github.com/Slackadays/Hajime), cd hajime, and issuing the two CMake commands above. Output of GDB: Thread 2 "hajime" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffff7ff8640 (LWP 52019)] 0x0000000000000000 in ?? () (gdb) bt #0 0x0000000000000000 in ?? () #1 0x0000000000510745 in std::thread::detach() () #2 0x000000000044ca76 in Server::startProgram (this=3D0x7022b0, method=3D.= ..) at /home/jackson/hajime/source/server.cpp:290 #3 0x000000000044ad15 in Server::startServer (this=3D0x7022b0, confFile=3D= ...) at /home/jackson/hajime/source/server.cpp:112 #4 0x0000000000449d8f in std::__invoke_impl, std::allocator >), std::shared_ptr, std::__cxx11::basic_string, std::allocator > > (__f=3D @0x6ff0c8: (void (Server::*)(Server * const, std::__cxx11::basic_string, std::allocator >)) 0x44a298 , std::allocator >)>, __t=3D...) at /usr/include/c++/11/bits/invoke.h:74 #5 0x0000000000449c45 in std::__invoke, std::allocator >), std::shared_ptr, std::__cxx11::basic_string, std::allocator > > (__fn=3D @0x6ff0c8: (void (Server::*)(Server * const, std::__cxx11::basic_string, std::allocator >)) 0x44a298 , std::allocator >)>) at /usr/include/c++/11/bits/invoke.h:96 #6 0x0000000000449b35 in std::thread::_Invoker, std::allocator >), std::shared_ptr, std::__cxx11::basic_string, std::allocator > > >::_M_invoke<0ul, 1ul, 2ul> (this=3D0x6ff098) at /usr/include/c++/11/bits/std_thread.h:253 #7 0x000000000044958a in std::thread::_Invoker, std::allocator >), std::shared_ptr, std::__cxx11::basic_string, std::allocator > > >::operator() (this=3D0x6ff098) at /usr/include/c++/11/bits/std_thread.h:260 #8 0x0000000000449422 in std::thread::_State_impl, std::allocator >), std::shared_ptr, std::__cxx11::basic_string, std::allocator > > > >::_M_run ( this=3D0x6ff090) at /usr/include/c++/11/bits/std_thread.h:211 #9 0x00000000005104b4 in execute_native_thread_routine () #10 0x000000000058a877 in start_thread () #11 0x000000000060d814 in clone () (gdb)=