public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/6910] New: getpid() wrong in child's signal handler after clone()
@ 2008-09-22 11:45 mtk dot manpages at gmail dot com
2008-09-22 11:48 ` [Bug libc/6910] " mtk dot manpages at gmail dot com
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: mtk dot manpages at gmail dot com @ 2008-09-22 11:45 UTC (permalink / raw)
To: glibc-bugs
As at glibc 2.8, glibc caching of PIDs for getpid() means that if a signal is
delivered to the child soon after a clone() (i.e., before the child has a
chance to update the cache), then a call to getpid() within the signal handler
in the child returns the wrong value.
To test this, the attached program creates a child process that continuously
sends a SIGQUIT signal to the process group. Meanwhile the parent loops
creating children that sleep for a moment, and then terminate. In that time,
the SIGQUIT handler will be invoked in the child. If the getpid() cache has not
yet been updated, then it will (occasionally) happen that the values returned by
glibc's getpid() and a raw syscall(SYS_getpid) will not match. When that
occurs, the child prints a message noting the mismatch.
If this program is invoked with any command-line argument, then it uses fork()
instead of clone(). This can be used to show that the problem does not occur
for fork().
--
Summary: getpid() wrong in child's signal handler after clone()
Product: glibc
Version: 2.8
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: mtk dot manpages at gmail dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=6910
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/6910] getpid() wrong in child's signal handler after clone()
2008-09-22 11:45 [Bug libc/6910] New: getpid() wrong in child's signal handler after clone() mtk dot manpages at gmail dot com
@ 2008-09-22 11:48 ` mtk dot manpages at gmail dot com
2008-09-22 11:49 ` mtk dot manpages at gmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: mtk dot manpages at gmail dot com @ 2008-09-22 11:48 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From mtk dot manpages at gmail dot com 2008-09-22 11:47 -------
Created an attachment (id=2959)
--> (http://sourceware.org/bugzilla/attachment.cgi?id=2959&action=view)
Test program
When running this program on glibc 2.8 on an i386 system, I see output such as
the following:
$ ./clone_getpid_sighandler_bug
Before clone getpid() = 1991
sigsender PID = 1993
getpid() mismatch (loop=2710): getpid()=1991; syscall(SYS_getpid)=4823
getpid() mismatch (loop=5383): getpid()=1991; syscall(SYS_getpid)=7504
getpid() mismatch (loop=5383): getpid()=1991; syscall(SYS_getpid)=7504
--
http://sourceware.org/bugzilla/show_bug.cgi?id=6910
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/6910] getpid() wrong in child's signal handler after clone()
2008-09-22 11:45 [Bug libc/6910] New: getpid() wrong in child's signal handler after clone() mtk dot manpages at gmail dot com
2008-09-22 11:48 ` [Bug libc/6910] " mtk dot manpages at gmail dot com
@ 2008-09-22 11:49 ` mtk dot manpages at gmail dot com
2008-09-22 23:57 ` drepper at redhat dot com
2008-09-23 1:13 ` mtk dot manpages at gmail dot com
3 siblings, 0 replies; 6+ messages in thread
From: mtk dot manpages at gmail dot com @ 2008-09-22 11:49 UTC (permalink / raw)
To: glibc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |michael dot kerrisk at gmail
| |dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=6910
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/6910] getpid() wrong in child's signal handler after clone()
2008-09-22 11:45 [Bug libc/6910] New: getpid() wrong in child's signal handler after clone() mtk dot manpages at gmail dot com
2008-09-22 11:48 ` [Bug libc/6910] " mtk dot manpages at gmail dot com
2008-09-22 11:49 ` mtk dot manpages at gmail dot com
@ 2008-09-22 23:57 ` drepper at redhat dot com
2008-09-23 1:13 ` mtk dot manpages at gmail dot com
3 siblings, 0 replies; 6+ messages in thread
From: drepper at redhat dot com @ 2008-09-22 23:57 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From drepper at redhat dot com 2008-09-22 23:56 -------
You cannot use clone this way. In fact, nobody should use clone. There are
assumptions made in the system about the way clone is used. If you want to use
clone you have to do everything yourself, including preparing the thread descriptor.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |WONTFIX
http://sourceware.org/bugzilla/show_bug.cgi?id=6910
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/6910] getpid() wrong in child's signal handler after clone()
2008-09-22 11:45 [Bug libc/6910] New: getpid() wrong in child's signal handler after clone() mtk dot manpages at gmail dot com
` (2 preceding siblings ...)
2008-09-22 23:57 ` drepper at redhat dot com
@ 2008-09-23 1:13 ` mtk dot manpages at gmail dot com
3 siblings, 0 replies; 6+ messages in thread
From: mtk dot manpages at gmail dot com @ 2008-09-23 1:13 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From mtk dot manpages at gmail dot com 2008-09-23 01:12 -------
(In reply to comment #2)
> You cannot use clone this way. In fact, nobody should use clone. There are
> assumptions made in the system about the way clone is used. If you want to
use
> clone you have to do everything yourself, including preparing the thread
descriptor.
All of this does kind of beg the question: why does glibc provide a clone()
wrapper then?
--
http://sourceware.org/bugzilla/show_bug.cgi?id=6910
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libc/6910] getpid() wrong in child's signal handler after clone()
[not found] <bug-6910-131@http.sourceware.org/bugzilla/>
@ 2014-07-02 7:22 ` fweimer at redhat dot com
0 siblings, 0 replies; 6+ messages in thread
From: fweimer at redhat dot com @ 2014-07-02 7:22 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=6910
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Flags| |security-
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-07-02 7:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-22 11:45 [Bug libc/6910] New: getpid() wrong in child's signal handler after clone() mtk dot manpages at gmail dot com
2008-09-22 11:48 ` [Bug libc/6910] " mtk dot manpages at gmail dot com
2008-09-22 11:49 ` mtk dot manpages at gmail dot com
2008-09-22 23:57 ` drepper at redhat dot com
2008-09-23 1:13 ` mtk dot manpages at gmail dot com
[not found] <bug-6910-131@http.sourceware.org/bugzilla/>
2014-07-02 7:22 ` fweimer at redhat dot com
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).