Fix getpid in new threads after fork
A message that is not in the archive (sent off-list or not yet received): [email protected]
Randolph,
Look familiar?
---------- Forwarded message ----------
From: Daniel Jacobowitz <[email protected]>
Date: Jul 31, 2006 12:15 PM
Subject: Fix getpid in new threads after fork
To: [email protected]
I noticed a failure with thread cancellation after fork, which turned out to be caused by the si_pid sanity check in sigcancel_handler. The PID was stale. This happened because the main program created a thread, joined it, and then forked. The cached thread was reused with a stale PID.
Patch and testcase attached. Tested on x86_64-pc-linux-gnu.
--
Daniel Jacobowitz
CodeSourcery
2006-07-31 Daniel Jacobowitz <[email protected]>
* Makefile (tests): Run tst-getpid3.
* allocatestack.c (__reclaim_stacks): Reset the PID on cached stacks.
* tst-getpid3.c: New test.
Index: nptl/Makefile
===================================================================
RCS file: /cvs/glibc/libc/nptl/Makefile,v
retrieving revision 1.180
Makefile 31 Jul 2006 16:04:16 -0000 renamed from Makefile 28 Mar 2006 04:13:27 -0000 1.180 +1 -1
@@ -251,7 +251,7 @@ tests = tst-typesizes \ tst-backtrace1 \ tst-oddstacklimit \ tst-vfork1 tst-vfork2 tst-vfork1x tst-vfork2x \ - tst-getpid1 tst-getpid2 \ + tst-getpid1 tst-getpid2 tst-getpid3 \ tst-initializers1 $(patsubst %,tst-initializers1-%,c89 gnu89 c99 gnu99)
xtests = tst-setuid1 tst-setuid1-static
Index: nptl/allocatestack.c
===================================================================
RCS file: /cvs/glibc/libc/nptl/allocatestack.c,v
retrieving revision 1.62
allocatestack.c 31 Jul 2006 16:04:17 -0000 renamed from allocatestack.c 28 Mar 2006 04:14:00 -0000 1.62 +9 -0
@@ -758,6 +758,15 @@ __reclaim_stacks (void) } } + /* Reset the PIDs in any cached stacks. */ + list_for_each (runp, &stack_cache) + { + struct pthread *curp; + + curp = list_entry (runp, struct pthread, list); + curp->pid = self->pid; + } + /* Add the stack of all running threads to the cache. */ list_splice (&stack_used, &stack_cache);
Index: nptl/tst-getpid3.c
===================================================================
RCS file: nptl/tst-getpid3.c
tst-getpid3.c 31 Jul 2006 16:04:17 -0000 renamed from dev/null 1 Jan 1970 00:00:00 -0000 +112 -0
112 lines not on this page · raw message
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux