[Bug libgcc/87189] libgcc/gthr-posix.h (__gthread_active_p) makes unwarranted assumptions about libpthread.a

2024-04-25 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189
Bug 87189 depends on bug 78017, which changed state.

Bug 78017 Summary: weak reference usage in gthr-posix.h (__gthread*) is broken 
with new enough glibc (GTHREAD_USE_WEAK can be defined to 0 now)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78017

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

[Bug libgcc/87189] libgcc/gthr-posix.h (__gthread_active_p) makes unwarranted assumptions about libpthread.a

2024-04-08 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189

--- Comment #13 from Andrew Pinski  ---
*** Bug 114646 has been marked as a duplicate of this bug. ***

[Bug libgcc/87189] libgcc/gthr-posix.h (__gthread_active_p) makes unwarranted assumptions about libpthread.a

2024-04-08 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189

Andrew Pinski  changed:

   What|Removed |Added

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

--- Comment #12 from Andrew Pinski  ---
Dup.

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

[Bug libgcc/87189] libgcc/gthr-posix.h (__gthread_active_p) makes unwarranted assumptions about libpthread.a

2024-04-08 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189

Andrew Pinski  changed:

   What|Removed |Added

 CC||hjl.tools at gmail dot com

--- Comment #11 from Andrew Pinski  ---
*** Bug 114646 has been marked as a duplicate of this bug. ***

[Bug libgcc/87189] libgcc/gthr-posix.h (__gthread_active_p) makes unwarranted assumptions about libpthread.a

2024-04-08 Thread bruno at clisp dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189

--- Comment #10 from Bruno Haible  ---
It is fixed in
- glibc 2.35 + gcc 11.4 (verified on Ubuntu 22.04),
- glibc 2.39 + gcc 13.2.1 (verified on Arch Linux 2024.04).

[Bug libgcc/87189] libgcc/gthr-posix.h (__gthread_active_p) makes unwarranted assumptions about libpthread.a

2018-09-03 Thread ppluzhnikov at google dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189

--- Comment #9 from Paul Pluzhnikov  ---
Thanks, H.J.

https://sourceware.org/bugzilla/show_bug.cgi?id=5784 has a few references, and
in particular https://sourceware.org/ml/libc-alpha/2012-09/msg00192.html is
important to consider.

[Bug libgcc/87189] libgcc/gthr-posix.h (__gthread_active_p) makes unwarranted assumptions about libpthread.a

2018-09-03 Thread hjl.tools at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189

--- Comment #8 from H.J. Lu  ---
Here is a very old proposal:

https://groups.google.com/forum/#!msg/generic-abi/K1lUiNsmM6c/Pl9-7ngPVXIJ

I am not sure if it will completely fix:

https://sourceware.org/bugzilla/show_bug.cgi?id=5784

[Bug libgcc/87189] libgcc/gthr-posix.h (__gthread_active_p) makes unwarranted assumptions about libpthread.a

2018-09-03 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189

--- Comment #7 from Jakub Jelinek  ---
gthr.h is used heavily e.g. in libstdc++, so your solution doesn't really work
at all.

[Bug libgcc/87189] libgcc/gthr-posix.h (__gthread_active_p) makes unwarranted assumptions about libpthread.a

2018-09-03 Thread ppluzhnikov at google dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189

--- Comment #6 from Paul Pluzhnikov  ---
(In reply to Jakub Jelinek from comment #5)

> Because it is very expensive.

One impractical solution is to require '-pthread' on the compile and link line,
and link a libgcc_mt that has non-weak references to pthread_* functions.

This will force end users to finally build their programs with correct command
line :-)

[Bug libgcc/87189] libgcc/gthr-posix.h (__gthread_active_p) makes unwarranted assumptions about libpthread.a

2018-09-03 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189

--- Comment #5 from Jakub Jelinek  ---
(In reply to Paul Pluzhnikov from comment #4)
> (In reply to Jakub Jelinek from comment #3)
> > This is a glibc bug
> 
> I (obviously) disagree.
> 
> , coming up with a set of weakref checks for gthr.h that
> > would satisfy static linking of glibc and all possible combinations of
> > included vs. non-included objects is impossible.
> 
> If you call pthread_mutex_lock (or any other function) via weakref, then you
> should ensure that the function is actually available.
> 
> AFAICT, libgcc only calls a few pthread_* functions. Why is it hard to check
> that *all* of them are present?

Because it is very expensive.  Each of those tests requires a dynamic
relocation, GOT read every time it is checked, bloats the code size, etc.

[Bug libgcc/87189] libgcc/gthr-posix.h (__gthread_active_p) makes unwarranted assumptions about libpthread.a

2018-09-03 Thread ppluzhnikov at google dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189

--- Comment #4 from Paul Pluzhnikov  ---
(In reply to Jakub Jelinek from comment #3)
> This is a glibc bug

I (obviously) disagree.

, coming up with a set of weakref checks for gthr.h that
> would satisfy static linking of glibc and all possible combinations of
> included vs. non-included objects is impossible.

If you call pthread_mutex_lock (or any other function) via weakref, then you
should ensure that the function is actually available.

AFAICT, libgcc only calls a few pthread_* functions. Why is it hard to check
that *all* of them are present?

> E.g. Fedora/RHEL ld -r libpthread.a objects into a single exactly because of 
> this.

That is a workaround, not a fix. And it has significant negative effects in the
resulting program code size.

> There are many dups of this both on the gcc side and glibc side.

Well, I think GCC and GLIBC developers need to sit down and decide whose bug it
is, and fix it once and for all :-)

[Bug libgcc/87189] libgcc/gthr-posix.h (__gthread_active_p) makes unwarranted assumptions about libpthread.a

2018-09-03 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189

--- Comment #3 from Jakub Jelinek  ---
This is a glibc bug, coming up with a set of weakref checks for gthr.h that
would satisfy static linking of glibc and all possible combinations of included
vs. non-included objects is impossible.
E.g. Fedora/RHEL ld -r libpthread.a objects into a single exactly because of
this.
The other alternative is to add (for libpthread.a) dependencies in betweeh the
*.o objects so that a reasonable set is always linked together, or just link
with --whole-archive -lpthread --no-whole-archive.
There are many dups of this both on the gcc side and glibc side.

[Bug libgcc/87189] libgcc/gthr-posix.h (__gthread_active_p) makes unwarranted assumptions about libpthread.a

2018-09-03 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189

Richard Biener  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org,
   ||rguenth at gcc dot gnu.org

--- Comment #2 from Richard Biener  ---
Hmm, "interesting" case.  Not sure what to do about these...

[Bug libgcc/87189] libgcc/gthr-posix.h (__gthread_active_p) makes unwarranted assumptions about libpthread.a

2018-09-02 Thread ppluzhnikov at google dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87189

--- Comment #1 from Paul Pluzhnikov  ---
Crash stack for reference:

Program received signal SIGSEGV, Segmentation fault.
0x in ?? ()
(gdb) bt
#0  0x in ?? ()
#1  0x00477f7c in __gthread_mutex_lock (__mutex=0x6a7380
) at ./gthr-default.h:748
#2  __register_frame_info_bases (begin=, ob=0x6a2300 ,
tbase=, dbase=) at
../../../libgcc/unwind-dw2-fde.c:103
#3  0x00400acd in frame_dummy ()
#4  0x0001 in ?? ()
#5  0x0040194c in __libc_csu_init (argc=-9472, argc@entry=1,
argv=argv@entry=0x7fffdc78, envp=0x7fffdc88) at elf-init.c:88
#6  0x00401170 in __libc_start_main (main=0x400add , argc=1,
argv=0x7fffdc78, init=0x4018d0 <__libc_csu_init>, fini=0x401970
<__libc_csu_fini>, rtld_fini=0x0, stack_end=0x7fffdc68) at
../csu/libc-start.c:264
#7  0x004009fa in _start () at ../sysdeps/x86_64/start.S:120