public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug dynamic-link/29740] New: Race condition between pthread_exit and fork @ 2022-11-01 14:12 prekgeo at yahoo dot com 2022-11-01 14:14 ` [Bug dynamic-link/29740] " prekgeo at yahoo dot com ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: prekgeo at yahoo dot com @ 2022-11-01 14:12 UTC (permalink / raw) To: glibc-bugs https://sourceware.org/bugzilla/show_bug.cgi?id=29740 Bug ID: 29740 Summary: Race condition between pthread_exit and fork Product: glibc Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: dynamic-link Assignee: unassigned at sourceware dot org Reporter: prekgeo at yahoo dot com Target Milestone: --- Created attachment 14427 --> https://sourceware.org/bugzilla/attachment.cgi?id=14427&action=edit glibc patch to add delay in do_lookup_x I have observed a crash in a Python program that uses threads and fork. Below, I attach the following: * a patch for the latest glibc master (commit b4174c28d21e1672ef3cc15a058558e97b8471c6) that introduces a delay to force the race condition. * a minimal C reproduction. My understanding of the problem is that the following sequence of events takes place: parent: main-thread: starts thread-1 parent: thread-1: exits parent: thread-1: tries to call _Unwind_Find_FDE parent: thread-1: ld.so loads libgcc_s.so in memory parent: main-thread: fork() parent: thread-1: resolves _Unwind_Find_FDE@got.plt child: main-thread: starts thread-1 child: thread-1: exits child: thread-1: calls _Unwind_Find_FDE using the unresolved _Unwind_Find_FDE@got.plt The child process crashes with a SIGSEGV with the following backtrace: #0 0x0000000000003230 in ?? () #1 0x00007ffff75c2868 in uw_frame_state_for (context=0x7ffff7dcdc70, fs=0x7ffff7dcdab0) at ../../../src/libgcc/unwind-dw2.c:1263 #2 0x00007ffff75c3a20 in uw_init_context_1 (context=0x7ffff7dcdc70, outer_cfa=0x7ffff7dcdea0, outer_ra=0x7ffff7e64e36 <__GI___pthread_unwind+70>) at ../../../src/libgcc/unwind-dw2.c:1592 #3 0x00007ffff75c431a in _Unwind_ForcedUnwind (exc=0x7ffff7dced30, stop=stop@entry=0x7ffff7e64ca0 <unwind_stop>, stop_argument=0x7ffff7dcdef0) at ../../../src/libgcc/unwind.inc:211 #4 0x00007ffff7e64e36 in __GI___pthread_unwind (buf=<optimized out>) at unwind.c:130 #5 0x00007ffff7e5ddba in __do_cancel () at ../sysdeps/nptl/pthreadP.h:276 #6 __GI___pthread_exit (value=0x0) at pthread_exit.c:36 #7 0x00007ffff7fbf283 in ?? () #8 0x0000000000000000 in ?? () 0x3230 is the value of _Unwind_Find_FDE@got.plt in the binary: $ gdb -q /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 (gdb) p '_Unwind_Find_FDE@got.plt' $1 = (<text from jump slot in .got.plt, no debug info>) 0x3230 I have also a Python reproduction that fails without the forced delay and by just enabling LD_DEBUG=all (which seems to add the needed delays). Let me know if it's valuable to attach in this bug. -- You are receiving this mail because: You are on the CC list for the bug. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug dynamic-link/29740] Race condition between pthread_exit and fork 2022-11-01 14:12 [Bug dynamic-link/29740] New: Race condition between pthread_exit and fork prekgeo at yahoo dot com @ 2022-11-01 14:14 ` prekgeo at yahoo dot com 2022-11-01 14:15 ` prekgeo at yahoo dot com ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: prekgeo at yahoo dot com @ 2022-11-01 14:14 UTC (permalink / raw) To: glibc-bugs https://sourceware.org/bugzilla/show_bug.cgi?id=29740 --- Comment #1 from George Prekas <prekgeo at yahoo dot com> --- Created attachment 14428 --> https://sourceware.org/bugzilla/attachment.cgi?id=14428&action=edit Reproduction -- You are receiving this mail because: You are on the CC list for the bug. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug dynamic-link/29740] Race condition between pthread_exit and fork 2022-11-01 14:12 [Bug dynamic-link/29740] New: Race condition between pthread_exit and fork prekgeo at yahoo dot com 2022-11-01 14:14 ` [Bug dynamic-link/29740] " prekgeo at yahoo dot com @ 2022-11-01 14:15 ` prekgeo at yahoo dot com 2022-11-01 15:03 ` schwab@linux-m68k.org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: prekgeo at yahoo dot com @ 2022-11-01 14:15 UTC (permalink / raw) To: glibc-bugs https://sourceware.org/bugzilla/show_bug.cgi?id=29740 George Prekas <prekgeo at yahoo dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |prekgeo at yahoo dot com -- You are receiving this mail because: You are on the CC list for the bug. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug dynamic-link/29740] Race condition between pthread_exit and fork 2022-11-01 14:12 [Bug dynamic-link/29740] New: Race condition between pthread_exit and fork prekgeo at yahoo dot com 2022-11-01 14:14 ` [Bug dynamic-link/29740] " prekgeo at yahoo dot com 2022-11-01 14:15 ` prekgeo at yahoo dot com @ 2022-11-01 15:03 ` schwab@linux-m68k.org 2022-11-01 16:38 ` fw at deneb dot enyo.de ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: schwab@linux-m68k.org @ 2022-11-01 15:03 UTC (permalink / raw) To: glibc-bugs https://sourceware.org/bugzilla/show_bug.cgi?id=29740 Andreas Schwab <schwab@linux-m68k.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #2 from Andreas Schwab <schwab@linux-m68k.org> --- The child may only call async-signal-safe functions, which pthread_create isn't. -- You are receiving this mail because: You are on the CC list for the bug. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug dynamic-link/29740] Race condition between pthread_exit and fork 2022-11-01 14:12 [Bug dynamic-link/29740] New: Race condition between pthread_exit and fork prekgeo at yahoo dot com ` (2 preceding siblings ...) 2022-11-01 15:03 ` schwab@linux-m68k.org @ 2022-11-01 16:38 ` fw at deneb dot enyo.de 2022-11-01 16:50 ` prekgeo at yahoo dot com 2022-11-01 17:01 ` fw at deneb dot enyo.de 5 siblings, 0 replies; 7+ messages in thread From: fw at deneb dot enyo.de @ 2022-11-01 16:38 UTC (permalink / raw) To: glibc-bugs https://sourceware.org/bugzilla/show_bug.cgi?id=29740 Florian Weimer <fw at deneb dot enyo.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fw at deneb dot enyo.de --- Comment #3 from Florian Weimer <fw at deneb dot enyo.de> --- What's your glibc version? I don't expect unwind-link to have this problem. See __libc_unwind_link_after_fork. The unwind-link facility was added in glibc 2.34. -- You are receiving this mail because: You are on the CC list for the bug. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug dynamic-link/29740] Race condition between pthread_exit and fork 2022-11-01 14:12 [Bug dynamic-link/29740] New: Race condition between pthread_exit and fork prekgeo at yahoo dot com ` (3 preceding siblings ...) 2022-11-01 16:38 ` fw at deneb dot enyo.de @ 2022-11-01 16:50 ` prekgeo at yahoo dot com 2022-11-01 17:01 ` fw at deneb dot enyo.de 5 siblings, 0 replies; 7+ messages in thread From: prekgeo at yahoo dot com @ 2022-11-01 16:50 UTC (permalink / raw) To: glibc-bugs https://sourceware.org/bugzilla/show_bug.cgi?id=29740 --- Comment #4 from George Prekas <prekgeo at yahoo dot com> --- This was tested and reproduces on the latest master (commit b4174c28d21e1672ef3cc15a058558e97b8471c6). After reading Andreas' response, I found this snippet in fork's man page which renders the reproduction code invalid: * After a fork() in a multithreaded program, the child can safely call only async-signal-safe functions (see signal-safety(7)) until such time as it calls execve(2). -- You are receiving this mail because: You are on the CC list for the bug. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug dynamic-link/29740] Race condition between pthread_exit and fork 2022-11-01 14:12 [Bug dynamic-link/29740] New: Race condition between pthread_exit and fork prekgeo at yahoo dot com ` (4 preceding siblings ...) 2022-11-01 16:50 ` prekgeo at yahoo dot com @ 2022-11-01 17:01 ` fw at deneb dot enyo.de 5 siblings, 0 replies; 7+ messages in thread From: fw at deneb dot enyo.de @ 2022-11-01 17:01 UTC (permalink / raw) To: glibc-bugs https://sourceware.org/bugzilla/show_bug.cgi?id=29740 --- Comment #5 from Florian Weimer <fw at deneb dot enyo.de> --- I see. So it's probably the half-completed dlopen that confuses the subprocess. We do this after fork: /* Reset the lock the dynamic loader uses to protect its data. */ __rtld_lock_initialize (GL(dl_load_lock)); /* Reset the lock protecting dynamic TLS related data. */ __rtld_lock_initialize (GL(dl_load_tls_lock)); That's unfortunately not particularly safe. -- You are receiving this mail because: You are on the CC list for the bug. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-11-01 17:01 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-11-01 14:12 [Bug dynamic-link/29740] New: Race condition between pthread_exit and fork prekgeo at yahoo dot com 2022-11-01 14:14 ` [Bug dynamic-link/29740] " prekgeo at yahoo dot com 2022-11-01 14:15 ` prekgeo at yahoo dot com 2022-11-01 15:03 ` schwab@linux-m68k.org 2022-11-01 16:38 ` fw at deneb dot enyo.de 2022-11-01 16:50 ` prekgeo at yahoo dot com 2022-11-01 17:01 ` fw at deneb dot enyo.de
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).