From owner-freebsd-hackers Fri Apr 27 13:38:26 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.musha.org (daemon.musha.org [61.122.44.178]) by hub.freebsd.org (Postfix) with ESMTP id C353D37B422 for ; Fri, 27 Apr 2001 13:38:21 -0700 (PDT) (envelope-from knu@iDaemons.org) Received: from archon.local.idaemons.org (archon.local.idaemons.org [192.168.1.32]) by mail.musha.org (Postfix) with ESMTP id 8A95E4DF22 for ; Sat, 28 Apr 2001 05:38:20 +0900 (JST) Date: Sat, 28 Apr 2001 05:38:20 +0900 Message-ID: <86zod213k3.wl@archon.local.idaemons.org> From: "Akinori MUSHA" To: hackers@FreeBSD.org Subject: kern/26705 In-Reply-To: <200104191453.f3JErb999480@freefall.freebsd.org> References: <200104191453.f3JErb999480@freefall.freebsd.org> User-Agent: Wanderlust/2.5.4 (Smooth) SEMI/1.14.2 (=?ISO-8859-1?Q?Daish=F2?= =?ISO-8859-1?Q?ji?=) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386--freebsd) Organization: Associated I. Daemons X-PGP-Public-Key: finger knu@FreeBSD.org X-PGP-Fingerprint: 081D 099C 1705 861D 4B70 B04A 920B EFC7 9FD9 E1EE MIME-Version: 1.0 (generated by SEMI 1.14.2 - =?ISO-8859-1?Q?=22Daish=F2ji=22?=) Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, Please review the following patch. The previous fix against uthread_fork.c, pointed out by PR#25110, fixed the P_ALTSTACK problem, but it was not quite correct. The originator of PR#26705 claims that the problem is rooted in a bug of fork(2) regarding the alternate signal stack. See those PR's and follow the links in them for details. I'm really happy with the patch and have seen no problem yet, so I'd like to commit it unless someone finds any problem. Regards, Index: lib/libc_r/uthread/uthread_fork.c =================================================================== RCS file: /home/ncvs/src/lib/libc_r/uthread/uthread_fork.c,v retrieving revision 1.24 diff -u -r1.24 uthread_fork.c --- lib/libc_r/uthread/uthread_fork.c 2001/04/18 12:40:30 1.24 +++ lib/libc_r/uthread/uthread_fork.c 2001/04/19 12:01:42 @@ -32,7 +32,6 @@ * $FreeBSD: src/lib/libc_r/uthread/uthread_fork.c,v 1.24 2001/04/18 12:40:30 deischen Exp $ */ #include -#include #include #include #include @@ -113,16 +112,7 @@ else if (_pq_init(&_readyq) != 0) { /* Abort this application: */ PANIC("Cannot initialize priority ready queue."); - } else if ((_thread_sigstack.ss_sp == NULL) && - ((_thread_sigstack.ss_sp = malloc(SIGSTKSZ)) == NULL)) - PANIC("Unable to allocate alternate signal stack"); - else { - /* Install the alternate signal stack: */ - _thread_sigstack.ss_size = SIGSTKSZ; - _thread_sigstack.ss_flags = 0; - if (__sys_sigaltstack(&_thread_sigstack, NULL) != 0) - PANIC("Unable to install alternate signal stack"); - + } else { /* * Enter a loop to remove all threads other than * the running thread from the thread list: Index: sys/kern/kern_fork.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_fork.c,v retrieving revision 1.110 diff -u -r1.110 kern_fork.c --- sys/kern/kern_fork.c 2001/03/28 11:52:53 1.110 +++ sys/kern/kern_fork.c 2001/04/19 10:50:35 @@ -495,7 +495,7 @@ * Preserve some more flags in subprocess. PS_PROFIL has already * been preserved. */ - p2->p_flag |= p1->p_flag & P_SUGID; + p2->p_flag |= p1->p_flag & (P_SUGID | P_ALTSTACK); if (p1->p_session->s_ttyvp != NULL && p1->p_flag & P_CONTROLT) p2->p_flag |= P_CONTROLT; if (flags & RFPPWAIT) Index: sys/kern/kern_sig.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_sig.c,v retrieving revision 1.115 diff -u -r1.115 kern_sig.c --- sys/kern/kern_sig.c 2001/04/12 02:38:07 1.115 +++ sys/kern/kern_sig.c 2001/04/19 10:50:35 @@ -464,6 +464,7 @@ p->p_sigstk.ss_flags = SS_DISABLE; p->p_sigstk.ss_size = 0; p->p_sigstk.ss_sp = 0; + p->p_flag &= ~P_ALTSTACK; /* * Reset no zombies if child dies flag as Solaris does. */ -- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "Freeze this moment a little bit longer, make each impression a little bit stronger.. Experience slips away -- Time stand still" To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message