This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/6910] New: getpid() wrong in child's signal handler after clone()
- From: "mtk dot manpages at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 22 Sep 2008 11:44:12 -0000
- Subject: [Bug libc/6910] New: getpid() wrong in child's signal handler after clone()
- Reply-to: sourceware-bugzilla at sourceware dot org
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.