From owner-freebsd-threads@FreeBSD.ORG Mon Jun 28 11:07:03 2010 Return-Path: Delivered-To: freebsd-threads@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 159B81065670 for ; Mon, 28 Jun 2010 11:07:03 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 03FB98FC15 for ; Mon, 28 Jun 2010 11:07:03 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o5SB72RF086666 for ; Mon, 28 Jun 2010 11:07:02 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o5SB725X086664 for freebsd-threads@FreeBSD.org; Mon, 28 Jun 2010 11:07:02 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 28 Jun 2010 11:07:02 GMT Message-Id: <201006281107.o5SB725X086664@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-threads@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-threads@FreeBSD.org X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jun 2010 11:07:03 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o threa/141721 threads rtprio(1): (id|rt)prio priority resets when new thread o threa/141198 threads [libc] src/lib/libc/stdio does not properly initialize o threa/136345 threads Recursive read rwlocks in thread A cause deadlock with o threa/135673 threads databases/mysql50-server - MySQL query lock-ups on 7.2 o threa/133734 threads 32 bit libthr failing pthread_create() o threa/128922 threads threads hang with xorg running o threa/127225 threads bug in lib/libthr/thread/thr_init.c o threa/122923 threads 'nice' does not prevent background process from steali o threa/121336 threads lang/neko threading ok on UP, broken on SMP (FreeBSD 7 f threa/118715 threads kse problem o threa/116668 threads can no longer use jdk15 with libthr on -stable SMP o threa/116181 threads /dev/io-related io access permissions are not propagat o threa/115211 threads pthread_atfork misbehaves in initial thread o threa/110636 threads [request] gdb(1): using gdb with multi thread applicat o threa/110306 threads apache 2.0 segmentation violation when calling gethost o threa/103975 threads Implicit loading/unloading of libpthread.so may crash o threa/101323 threads [patch] fork(2) in threaded programs broken. s threa/100815 threads FBSD 5.5 broke nanosleep in libc_r s threa/94467 threads send(), sendto() and sendmsg() are not correct in libc s threa/84483 threads problems with devel/nspr and -lc_r on 4.x o threa/80992 threads abort() sometimes not caught by gdb depending on threa o threa/79887 threads [patch] freopen() isn't thread-safe o threa/79683 threads svctcp_create() fails if multiple threads call at the s threa/76694 threads fork cause hang in dup()/close() function in child (-l s threa/76690 threads fork hang in child for -lc_r f threa/72953 threads fork() unblocks blocked signals w/o PTHREAD_SCOPE_SYST s threa/69020 threads pthreads library leaks _gc_mutex s threa/49087 threads Signals lost in programs linked with libc_r s threa/48856 threads Setting SIGCHLD to SIG_IGN still leaves zombies under s threa/40671 threads pthread_cancel doesn't remove thread from condition qu s threa/39922 threads [threads] [patch] Threaded applications executed with s threa/37676 threads libc_r: msgsnd(), msgrcv(), pread(), pwrite() need wra s threa/34536 threads accept() blocks other threads s threa/32295 threads [libc_r] [patch] pthread(3) dont dequeue signals s threa/30464 threads pthread mutex attributes -- pshared s threa/24632 threads libc_r delicate deviation from libc in handling SIGCHL s threa/24472 threads libc_r does not honor SO_SNDTIMEO/SO_RCVTIMEO socket o 37 problems total. From owner-freebsd-threads@FreeBSD.ORG Mon Jun 28 12:33:56 2010 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7425106564A; Mon, 28 Jun 2010 12:33:56 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 8E1B18FC0C; Mon, 28 Jun 2010 12:33:56 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 1277546B09; Mon, 28 Jun 2010 08:33:56 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id E3EBA8A03C; Mon, 28 Jun 2010 08:33:54 -0400 (EDT) From: John Baldwin To: threads@freebsd.org Date: Mon, 28 Jun 2010 08:33:54 -0400 User-Agent: KMail/1.12.1 (FreeBSD/7.3-CBSD-20100217; KDE/4.3.1; amd64; ; ) MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Message-Id: <201006280833.54224.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Mon, 28 Jun 2010 08:33:54 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: kib@freebsd.org Subject: SIGPIPE and threads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jun 2010 12:33:56 -0000 Currently when a thread performs a write(2) on a disconnected socket or a FIFO with no readers the SIGPIPE signal is posted to the entire process via psignal(). This means that the signal can be delivered to any thread in the process. However, it seems more intuitive to me that SIGPIPE should be sent to the "offending" thread similar to signals sent in response to traps via trapsignal(). POSIX seems to require this in that the description of the EPIPE error return value for write(2) and fflush(3) in the Open Group's online manpages both say that SIGPIPE should be sent to the current thread in addition to returning EPIPE: http://www.opengroup.org/onlinepubs/000095399/functions/write.html http://www.opengroup.org/onlinepubs/000095399/functions/fflush.html I have an untested (only compiled) patch below: Index: kern/uipc_syscalls.c =================================================================== --- kern/uipc_syscalls.c (revision 209571) +++ kern/uipc_syscalls.c (working copy) @@ -738,6 +738,7 @@ struct mbuf *control; enum uio_seg segflg; { + struct ksiginfo ksi; struct file *fp; struct uio auio; struct iovec *iov; @@ -793,8 +794,11 @@ /* Generation of SIGPIPE can be controlled per socket */ if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) && !(flags & MSG_NOSIGNAL)) { + ksiginfo_init(&ksi); + ksi.ksi_signo = SIGPIPE; + ksi.ksi_code = SI_KERNEL; PROC_LOCK(td->td_proc); - psignal(td->td_proc, SIGPIPE); + tdsignal(td->td_proc, td, SIGPIPE, &ksi); PROC_UNLOCK(td->td_proc); } } @@ -2379,6 +2383,7 @@ { #if (defined(INET) || defined(INET6)) && defined(SCTP) struct sctp_sndrcvinfo sinfo, *u_sinfo = NULL; + struct ksiginfo ksi; struct socket *so; struct file *fp = NULL; int use_rcvinfo = 1; @@ -2443,8 +2448,11 @@ /* Generation of SIGPIPE can be controlled per socket. */ if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) && !(uap->flags & MSG_NOSIGNAL)) { + ksiginfo_init(&ksi); + ksi.ksi_signo = SIGPIPE; + ksi.ksi_code = SI_KERNEL; PROC_LOCK(td->td_proc); - psignal(td->td_proc, SIGPIPE); + tdsignal(td->td_proc, td, SIGPIPE, &ksi); PROC_UNLOCK(td->td_proc); } } @@ -2483,6 +2491,7 @@ { #if (defined(INET) || defined(INET6)) && defined(SCTP) struct sctp_sndrcvinfo sinfo, *u_sinfo = NULL; + struct ksiginfo ksi; struct socket *so; struct file *fp = NULL; int use_rcvinfo = 1; @@ -2561,8 +2570,11 @@ /* Generation of SIGPIPE can be controlled per socket */ if (error == EPIPE && !(so->so_options & SO_NOSIGPIPE) && !(uap->flags & MSG_NOSIGNAL)) { + ksiginfo_init(&ksi); + ksi.ksi_signo = SIGPIPE; + ksi.ksi_code = SI_KERNEL; PROC_LOCK(td->td_proc); - psignal(td->td_proc, SIGPIPE); + tdsignal(td->td_proc, td, SIGPIPE, &ksi); PROC_UNLOCK(td->td_proc); } } Index: kern/sys_socket.c =================================================================== --- kern/sys_socket.c (revision 209571) +++ kern/sys_socket.c (working copy) @@ -92,6 +92,7 @@ int flags, struct thread *td) { struct socket *so = fp->f_data; + struct ksiginfo ksi; int error; #ifdef MAC @@ -101,8 +102,11 @@ #endif error = sosend(so, 0, uio, 0, 0, 0, uio->uio_td); if (error == EPIPE && (so->so_options & SO_NOSIGPIPE) == 0) { + ksiginfo_init(&ksi); + ksi.ksi_signo = SIGPIPE; + ksi.ksi_code = SI_KERNEL; PROC_LOCK(uio->uio_td->td_proc); - psignal(uio->uio_td->td_proc, SIGPIPE); + tdsignal(uio->uio_td->td_proc, uio->uio_td, SIGPIPE, &ksi); PROC_UNLOCK(uio->uio_td->td_proc); } return (error); Index: kern/sys_generic.c =================================================================== --- kern/sys_generic.c (revision 209571) +++ kern/sys_generic.c (working copy) @@ -509,6 +509,7 @@ off_t offset; int flags; { + struct ksiginfo ksi; ssize_t cnt; int error; #ifdef KTRACE @@ -531,8 +532,11 @@ error = 0; /* Socket layer is responsible for issuing SIGPIPE. */ if (fp->f_type != DTYPE_SOCKET && error == EPIPE) { + ksiginfo_init(&ksi); + ksi.ksi_signo = SIGPIPE; + ksi.ksi_code = SI_KERNEL; PROC_LOCK(td->td_proc); - psignal(td->td_proc, SIGPIPE); + tdsignal(td->td_proc, td, SIGPIPE, &ksi); PROC_UNLOCK(td->td_proc); } } -- John Baldwin From owner-freebsd-threads@FreeBSD.ORG Mon Jun 28 14:05:44 2010 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CCA301065672; Mon, 28 Jun 2010 14:05:44 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 1BA938FC17; Mon, 28 Jun 2010 14:05:43 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o5SE5YGp045279 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Jun 2010 17:05:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o5SE5YIL073172; Mon, 28 Jun 2010 17:05:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o5SE5YwD073171; Mon, 28 Jun 2010 17:05:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 28 Jun 2010 17:05:34 +0300 From: Kostik Belousov To: John Baldwin Message-ID: <20100628140534.GZ13238@deviant.kiev.zoral.com.ua> References: <201006280833.54224.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jHgdI7OefoZoiA5t" Content-Disposition: inline In-Reply-To: <201006280833.54224.jhb@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-2.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_50, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: threads@freebsd.org Subject: Re: SIGPIPE and threads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jun 2010 14:05:44 -0000 --jHgdI7OefoZoiA5t Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 28, 2010 at 08:33:54AM -0400, John Baldwin wrote: > Currently when a thread performs a write(2) on a disconnected socket or a= FIFO=20 > with no readers the SIGPIPE signal is posted to the entire process via=20 > psignal(). This means that the signal can be delivered to any thread in = the=20 > process. However, it seems more intuitive to me that SIGPIPE should be s= ent=20 > to the "offending" thread similar to signals sent in response to traps vi= a=20 > trapsignal(). POSIX seems to require this in that the description of the= =20 > EPIPE error return value for write(2) and fflush(3) in the Open Group's o= nline=20 > manpages both say that SIGPIPE should be sent to the current thread in=20 > addition to returning EPIPE: >=20 > http://www.opengroup.org/onlinepubs/000095399/functions/write.html >=20 > http://www.opengroup.org/onlinepubs/000095399/functions/fflush.html >=20 > I have an untested (only compiled) patch below: I think the patch is right, but, as you note, having a dedicated function that wraps automatic ksi initialization and tdsignal() call would be even better. >=20 > Index: kern/uipc_syscalls.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- kern/uipc_syscalls.c (revision 209571) > +++ kern/uipc_syscalls.c (working copy) > @@ -738,6 +738,7 @@ > struct mbuf *control; > enum uio_seg segflg; > { > + struct ksiginfo ksi; > struct file *fp; > struct uio auio; > struct iovec *iov; > @@ -793,8 +794,11 @@ > /* Generation of SIGPIPE can be controlled per socket */ > if (error =3D=3D EPIPE && !(so->so_options & SO_NOSIGPIPE) && > !(flags & MSG_NOSIGNAL)) { > + ksiginfo_init(&ksi); > + ksi.ksi_signo =3D SIGPIPE; > + ksi.ksi_code =3D SI_KERNEL; > PROC_LOCK(td->td_proc); > - psignal(td->td_proc, SIGPIPE); > + tdsignal(td->td_proc, td, SIGPIPE, &ksi); > PROC_UNLOCK(td->td_proc); > } > } > @@ -2379,6 +2383,7 @@ > { > #if (defined(INET) || defined(INET6)) && defined(SCTP) > struct sctp_sndrcvinfo sinfo, *u_sinfo =3D NULL; > + struct ksiginfo ksi; > struct socket *so; > struct file *fp =3D NULL; > int use_rcvinfo =3D 1; > @@ -2443,8 +2448,11 @@ > /* Generation of SIGPIPE can be controlled per socket. */ > if (error =3D=3D EPIPE && !(so->so_options & SO_NOSIGPIPE) && > !(uap->flags & MSG_NOSIGNAL)) { > + ksiginfo_init(&ksi); > + ksi.ksi_signo =3D SIGPIPE; > + ksi.ksi_code =3D SI_KERNEL; > PROC_LOCK(td->td_proc); > - psignal(td->td_proc, SIGPIPE); > + tdsignal(td->td_proc, td, SIGPIPE, &ksi); > PROC_UNLOCK(td->td_proc); > } > } > @@ -2483,6 +2491,7 @@ > { > #if (defined(INET) || defined(INET6)) && defined(SCTP) > struct sctp_sndrcvinfo sinfo, *u_sinfo =3D NULL; > + struct ksiginfo ksi; > struct socket *so; > struct file *fp =3D NULL; > int use_rcvinfo =3D 1; > @@ -2561,8 +2570,11 @@ > /* Generation of SIGPIPE can be controlled per socket */ > if (error =3D=3D EPIPE && !(so->so_options & SO_NOSIGPIPE) && > !(uap->flags & MSG_NOSIGNAL)) { > + ksiginfo_init(&ksi); > + ksi.ksi_signo =3D SIGPIPE; > + ksi.ksi_code =3D SI_KERNEL; > PROC_LOCK(td->td_proc); > - psignal(td->td_proc, SIGPIPE); > + tdsignal(td->td_proc, td, SIGPIPE, &ksi); > PROC_UNLOCK(td->td_proc); > } > } > Index: kern/sys_socket.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- kern/sys_socket.c (revision 209571) > +++ kern/sys_socket.c (working copy) > @@ -92,6 +92,7 @@ > int flags, struct thread *td) > { > struct socket *so =3D fp->f_data; > + struct ksiginfo ksi; > int error; > =20 > #ifdef MAC > @@ -101,8 +102,11 @@ > #endif > error =3D sosend(so, 0, uio, 0, 0, 0, uio->uio_td); > if (error =3D=3D EPIPE && (so->so_options & SO_NOSIGPIPE) =3D=3D 0) { > + ksiginfo_init(&ksi); > + ksi.ksi_signo =3D SIGPIPE; > + ksi.ksi_code =3D SI_KERNEL; > PROC_LOCK(uio->uio_td->td_proc); > - psignal(uio->uio_td->td_proc, SIGPIPE); > + tdsignal(uio->uio_td->td_proc, uio->uio_td, SIGPIPE, &ksi); > PROC_UNLOCK(uio->uio_td->td_proc); > } > return (error); > Index: kern/sys_generic.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- kern/sys_generic.c (revision 209571) > +++ kern/sys_generic.c (working copy) > @@ -509,6 +509,7 @@ > off_t offset; > int flags; > { > + struct ksiginfo ksi; > ssize_t cnt; > int error; > #ifdef KTRACE > @@ -531,8 +532,11 @@ > error =3D 0; > /* Socket layer is responsible for issuing SIGPIPE. */ > if (fp->f_type !=3D DTYPE_SOCKET && error =3D=3D EPIPE) { > + ksiginfo_init(&ksi); > + ksi.ksi_signo =3D SIGPIPE; > + ksi.ksi_code =3D SI_KERNEL; > PROC_LOCK(td->td_proc); > - psignal(td->td_proc, SIGPIPE); > + tdsignal(td->td_proc, td, SIGPIPE, &ksi); > PROC_UNLOCK(td->td_proc); > } > } >=20 > --=20 > John Baldwin --jHgdI7OefoZoiA5t Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkworC0ACgkQC3+MBN1Mb4huTACfX3Wdq2CxgCmwrqNmCbolHudz rdQAnjDBamwK3sbfOy+wcMH/tNo5Bpup =86qS -----END PGP SIGNATURE----- --jHgdI7OefoZoiA5t-- From owner-freebsd-threads@FreeBSD.ORG Mon Jun 28 15:28:25 2010 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 79CC61065674; Mon, 28 Jun 2010 15:28:25 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 3919B8FC14; Mon, 28 Jun 2010 15:28:24 +0000 (UTC) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.4/8.14.4/NETPLEX) with ESMTP id o5SFSN0J001569; Mon, 28 Jun 2010 11:28:23 -0400 (EDT) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.2.2 (mail.netplex.net [204.213.176.10]); Mon, 28 Jun 2010 11:28:23 -0400 (EDT) Date: Mon, 28 Jun 2010 11:28:23 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: John Baldwin In-Reply-To: <201006280833.54224.jhb@freebsd.org> Message-ID: References: <201006280833.54224.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: threads@freebsd.org, kib@freebsd.org Subject: Re: SIGPIPE and threads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jun 2010 15:28:25 -0000 On Mon, 28 Jun 2010, John Baldwin wrote: > Currently when a thread performs a write(2) on a disconnected socket or a FIFO > with no readers the SIGPIPE signal is posted to the entire process via > psignal(). This means that the signal can be delivered to any thread in the > process. However, it seems more intuitive to me that SIGPIPE should be sent > to the "offending" thread similar to signals sent in response to traps via > trapsignal(). POSIX seems to require this in that the description of the > EPIPE error return value for write(2) and fflush(3) in the Open Group's online > manpages both say that SIGPIPE should be sent to the current thread in > addition to returning EPIPE: Yes, I believe SIGPIPE should be treated as a synchronous signal and sent to the offending thread. -- DE From owner-freebsd-threads@FreeBSD.ORG Mon Jun 28 18:44:55 2010 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E8E24106564A for ; Mon, 28 Jun 2010 18:44:55 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id BDD498FC18 for ; Mon, 28 Jun 2010 18:44:55 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 5C9A446B2E; Mon, 28 Jun 2010 14:44:55 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 8D00A8A03C; Mon, 28 Jun 2010 14:44:50 -0400 (EDT) From: John Baldwin To: Kostik Belousov Date: Mon, 28 Jun 2010 14:44:49 -0400 User-Agent: KMail/1.12.1 (FreeBSD/7.3-CBSD-20100217; KDE/4.3.1; amd64; ; ) References: <201006280833.54224.jhb@freebsd.org> <20100628140534.GZ13238@deviant.kiev.zoral.com.ua> In-Reply-To: <20100628140534.GZ13238@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201006281444.50021.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Mon, 28 Jun 2010 14:44:50 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: threads@freebsd.org Subject: Re: SIGPIPE and threads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jun 2010 18:44:56 -0000 On Monday 28 June 2010 10:05:34 am Kostik Belousov wrote: > On Mon, Jun 28, 2010 at 08:33:54AM -0400, John Baldwin wrote: > > Currently when a thread performs a write(2) on a disconnected socket or a FIFO > > with no readers the SIGPIPE signal is posted to the entire process via > > psignal(). This means that the signal can be delivered to any thread in the > > process. However, it seems more intuitive to me that SIGPIPE should be sent > > to the "offending" thread similar to signals sent in response to traps via > > trapsignal(). POSIX seems to require this in that the description of the > > EPIPE error return value for write(2) and fflush(3) in the Open Group's online > > manpages both say that SIGPIPE should be sent to the current thread in > > addition to returning EPIPE: > > > > http://www.opengroup.org/onlinepubs/000095399/functions/write.html > > > > http://www.opengroup.org/onlinepubs/000095399/functions/fflush.html > > > > I have an untested (only compiled) patch below: > > I think the patch is right, but, as you note, having a dedicated > function that wraps automatic ksi initialization and tdsignal() > call would be even better. Ok, what I've done is to rename tdsignal() to tdsendsignals() and make it private to kern_sig.c. I then added 'tdsignal()' and 'tdksignal()' to the public KPI to mirror the existing psignal() and pksignal() routines. This patch can be found at http://www.freebsd.org/~jhb/patches/tdsignal.patch I then reworked the sigpipe patch to just convert calls to psignal() to tdsignal() instead. It is at http://www.freebsd.org/~jhb/patches/sigpipe.patch -- John Baldwin From owner-freebsd-threads@FreeBSD.ORG Mon Jun 28 19:16:29 2010 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3BED01065670; Mon, 28 Jun 2010 19:16:29 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id B4ACE8FC16; Mon, 28 Jun 2010 19:16:28 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o5SJGJJI075396 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 28 Jun 2010 22:16:19 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o5SJGJsx076273; Mon, 28 Jun 2010 22:16:19 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o5SJGJSX076272; Mon, 28 Jun 2010 22:16:19 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 28 Jun 2010 22:16:19 +0300 From: Kostik Belousov To: John Baldwin Message-ID: <20100628191619.GF13238@deviant.kiev.zoral.com.ua> References: <201006280833.54224.jhb@freebsd.org> <20100628140534.GZ13238@deviant.kiev.zoral.com.ua> <201006281444.50021.jhb@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7Y0jlJGlNwEFz8Iq" Content-Disposition: inline In-Reply-To: <201006281444.50021.jhb@freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-2.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_50, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: threads@freebsd.org Subject: Re: SIGPIPE and threads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jun 2010 19:16:29 -0000 --7Y0jlJGlNwEFz8Iq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 28, 2010 at 02:44:49PM -0400, John Baldwin wrote: > On Monday 28 June 2010 10:05:34 am Kostik Belousov wrote: > > On Mon, Jun 28, 2010 at 08:33:54AM -0400, John Baldwin wrote: > > > Currently when a thread performs a write(2) on a disconnected socket = or a FIFO=20 > > > with no readers the SIGPIPE signal is posted to the entire process vi= a=20 > > > psignal(). This means that the signal can be delivered to any thread= in the=20 > > > process. However, it seems more intuitive to me that SIGPIPE should = be sent=20 > > > to the "offending" thread similar to signals sent in response to trap= s via=20 > > > trapsignal(). POSIX seems to require this in that the description of= the=20 > > > EPIPE error return value for write(2) and fflush(3) in the Open Group= 's online=20 > > > manpages both say that SIGPIPE should be sent to the current thread i= n=20 > > > addition to returning EPIPE: > > >=20 > > > http://www.opengroup.org/onlinepubs/000095399/functions/write.html > > >=20 > > > http://www.opengroup.org/onlinepubs/000095399/functions/fflush.html > > >=20 > > > I have an untested (only compiled) patch below: > > > > I think the patch is right, but, as you note, having a dedicated > > function that wraps automatic ksi initialization and tdsignal() > > call would be even better. >=20 > Ok, what I've done is to rename tdsignal() to tdsendsignals() and make it > private to kern_sig.c. I then added 'tdsignal()' and 'tdksignal()' to the > public KPI to mirror the existing psignal() and pksignal() routines. >=20 > This patch can be found at http://www.freebsd.org/~jhb/patches/tdsignal.p= atch It seems that tdsendsignal() call in trapsignal() can be replaced by tdksignal(), unless I am mistaken. The same for psignal_event(). There is also a reference to tdsignal() in subr_sleepqueue.c comment, that is probably better to replace with tdsendsignal(). >=20 > I then reworked the sigpipe patch to just convert > calls to psignal() to tdsignal() instead. It is at > http://www.freebsd.org/~jhb/patches/sigpipe.patch Looks good. --7Y0jlJGlNwEFz8Iq Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkwo9QMACgkQC3+MBN1Mb4g2uQCgoR6eJFZG7p/nAnavGvFR7zwm iqoAoLSKIG5ezIlVejXdB3/BINFaFJZl =FuA1 -----END PGP SIGNATURE----- --7Y0jlJGlNwEFz8Iq-- From owner-freebsd-threads@FreeBSD.ORG Mon Jun 28 21:19:59 2010 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CDA441065673 for ; Mon, 28 Jun 2010 21:19:59 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 9F91C8FC17 for ; Mon, 28 Jun 2010 21:19:59 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 5576546B03; Mon, 28 Jun 2010 17:19:59 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 90CBC8A03C; Mon, 28 Jun 2010 17:19:53 -0400 (EDT) From: John Baldwin To: Kostik Belousov Date: Mon, 28 Jun 2010 17:19:44 -0400 User-Agent: KMail/1.12.1 (FreeBSD/7.3-CBSD-20100217; KDE/4.3.1; amd64; ; ) References: <201006280833.54224.jhb@freebsd.org> <201006281444.50021.jhb@freebsd.org> <20100628191619.GF13238@deviant.kiev.zoral.com.ua> In-Reply-To: <20100628191619.GF13238@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201006281719.44236.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Mon, 28 Jun 2010 17:19:53 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: threads@freebsd.org Subject: Re: SIGPIPE and threads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jun 2010 21:20:00 -0000 On Monday 28 June 2010 3:16:19 pm Kostik Belousov wrote: > On Mon, Jun 28, 2010 at 02:44:49PM -0400, John Baldwin wrote: > > On Monday 28 June 2010 10:05:34 am Kostik Belousov wrote: > > > On Mon, Jun 28, 2010 at 08:33:54AM -0400, John Baldwin wrote: > > > > Currently when a thread performs a write(2) on a disconnected socket or a FIFO > > > > with no readers the SIGPIPE signal is posted to the entire process via > > > > psignal(). This means that the signal can be delivered to any thread in the > > > > process. However, it seems more intuitive to me that SIGPIPE should be sent > > > > to the "offending" thread similar to signals sent in response to traps via > > > > trapsignal(). POSIX seems to require this in that the description of the > > > > EPIPE error return value for write(2) and fflush(3) in the Open Group's online > > > > manpages both say that SIGPIPE should be sent to the current thread in > > > > addition to returning EPIPE: > > > > > > > > http://www.opengroup.org/onlinepubs/000095399/functions/write.html > > > > > > > > http://www.opengroup.org/onlinepubs/000095399/functions/fflush.html > > > > > > > > I have an untested (only compiled) patch below: > > > > > > I think the patch is right, but, as you note, having a dedicated > > > function that wraps automatic ksi initialization and tdsignal() > > > call would be even better. > > > > Ok, what I've done is to rename tdsignal() to tdsendsignals() and make it > > private to kern_sig.c. I then added 'tdsignal()' and 'tdksignal()' to the > > public KPI to mirror the existing psignal() and pksignal() routines. > > > > This patch can be found at http://www.freebsd.org/~jhb/patches/tdsignal.patch > > It seems that tdsendsignal() call in trapsignal() can be replaced by > tdksignal(), unless I am mistaken. The same for psignal_event(). psignal_event() can't switch due to the !SIGEV_THREAD_ID case. For trapsignal() it could go either way. I sort of like having the 'p' argument passed to tdsendsignal() since we set p_code and p_sig just above the call. > There is also a reference to tdsignal() in subr_sleepqueue.c comment, > that is probably better to replace with tdsendsignal(). Good catch, fixed. > > I then reworked the sigpipe patch to just convert > > calls to psignal() to tdsignal() instead. It is at > > http://www.freebsd.org/~jhb/patches/sigpipe.patch > > Looks good. I'll write a regression test for this first, and once I'm happy with that I will commit. -- John Baldwin