[Bug libstdc++/104852] std::[j]thread::detach() still gives segmentation faults with glibc 2.34

2023-03-03 Thread aoliva at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104852

Alexandre Oliva  changed:

   What|Removed |Added

 CC||aoliva at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |aoliva at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

--- Comment #9 from Alexandre Oliva  ---
Should be fixed in the trunk (targeting 13).
AFAIK it fails with 12 and 11.
I know the patch works with 12, I've tested it there.

[Bug libstdc++/104852] std::[j]thread::detach() still gives segmentation faults with glibc 2.34

2023-03-03 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104852

--- Comment #8 from CVS Commits  ---
The master branch has been updated by Alexandre Oliva :

https://gcc.gnu.org/g:21edd841611a97442a6b95e8ec7e91ff8fd3a451

commit r13-6461-g21edd841611a97442a6b95e8ec7e91ff8fd3a451
Author: Alexandre Oliva 
Date:   Fri Mar 3 15:59:36 2023 -0300

link pthread_join from std::thread ctor

Like pthread_create, pthread_join may fail to be statically linked in
absent strong uses, so add to user code strong references to both when
std::thread objects are created.


for  libstdc++-v3/ChangeLog

PR libstdc++/104852
PR libstdc++/95989
PR libstdc++/52590
* include/bits/std_thread.h (thread::_M_thread_deps): New
static implicitly-inline member function.
(std::thread template ctor): Pass it to _M_start_thread.
* src/c++11/thread.cc (thread::_M_start_thread): Name depend
parameter, force it live on entry.

[Bug libstdc++/104852] std::[j]thread::detach() still gives segmentation faults with glibc 2.34

2022-03-09 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104852

Jonathan Wakely  changed:

   What|Removed |Added

   Last reconfirmed||2022-03-09
 Status|RESOLVED|NEW
 Ever confirmed|0   |1
 Resolution|DUPLICATE   |---

--- Comment #7 from Jonathan Wakely  ---
Ah, but it still won't help for glibc 2.34 because the pthread symbols are not
in libpthread.a now.

So this is different from PR 52590

[Bug libstdc++/104852] std::[j]thread::detach() still gives segmentation faults with glibc 2.34

2022-03-09 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104852

--- Comment #6 from Jonathan Wakely  ---
(In reply to Jackson Huff from comment #5)
> Just for reference, another person in bug 52590 had tried the same before
> but also had no luck.

No, they tried a different command, not the one I suggested.

I just checked out the code in an Ubuntu container and running make VERBOSE=1 I
see that the flags are added to the start of the command:

[100%] Linking CXX executable hajime
/usr/bin/cmake -E cmake_link_script CMakeFiles/hajime.dir/link.txt --verbose=1
/usr/bin/c++  -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -O3
-DNDEBUG -s -flto -fno-fat-lto-objects -flto=auto
CMakeFiles/hajime.dir/hajime.cpp.o CMakeFiles/hajime.dir/server.cpp.o
CMakeFiles/hajime.dir/server_features.cpp.o
CMakeFiles/hajime.dir/server_performance.cpp.o
CMakeFiles/hajime.dir/server_performance_counters.cpp.o
CMakeFiles/hajime.dir/getvarsfromfile.cpp.o CMakeFiles/hajime.dir/output.cpp.o
CMakeFiles/hajime.dir/installer.cpp.o CMakeFiles/hajime.dir/deduce.cpp.o
CMakeFiles/hajime.dir/languages.cpp.o CMakeFiles/hajime.dir/wizard.cpp.o
CMakeFiles/hajime.dir/constants.cpp.o -o hajime 

That is wrong:
https://web.archive.org/web/20210609020437/c-faq.com/lib/libsearch.html

[Bug libstdc++/104852] std::[j]thread::detach() still gives segmentation faults with glibc 2.34

2022-03-09 Thread lightningdzeyenr at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104852

--- Comment #5 from Jackson Huff  ---
Just for reference, another person in bug 52590 had tried the same before but
also had no luck.

[Bug libstdc++/104852] std::[j]thread::detach() still gives segmentation faults with glibc 2.34

2022-03-09 Thread lightningdzeyenr at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104852

--- Comment #4 from Jackson Huff  ---
(In reply to Jonathan Wakely from comment #2)
> For distros other than Red Hat (and Fedora, CentOS etc.) you need to use:
> 
> -Wl,--whole-archive -lpthread -Wl,--no-whole-archive
> 
> Otherwise the pthread symbols do not get pulled in by the linker.

This would seem like a fix, but applying those flags to both the ADD_FLAGS
variable and both manually specifying then in CMakeLists.txt made no difference
(I tried variations for hours but no dice).

[Bug libstdc++/104852] std::[j]thread::detach() still gives segmentation faults with glibc 2.34

2022-03-09 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104852

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #3 from Jonathan Wakely  ---
See PR 52590

*** This bug has been marked as a duplicate of bug 52590 ***

[Bug libstdc++/104852] std::[j]thread::detach() still gives segmentation faults with glibc 2.34

2022-03-09 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104852

--- Comment #2 from Jonathan Wakely  ---
This is the usual problem with weak symbols and static linking.

For distros other than Red Hat (and Fedora, CentOS etc.) you need to use:

-Wl,--whole-archive -lpthread -Wl,--no-whole-archive

Otherwise the pthread symbols do not get pulled in by the linker.

For GCC 12 and Glibc 2.34 that isn't needed, since r12-5108

[Bug libstdc++/104852] std::[j]thread::detach() still gives segmentation faults with glibc 2.34

2022-03-08 Thread lightningdzeyenr at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104852

--- Comment #1 from Jackson Huff  ---
Note that my CMake command includes -lpthread even though CMake has been
configured to link it already with -pthread, so when reproducing it, remove
-lpthread to better replicate the situation (I only realized this after
posting).