From owner-freebsd-current Mon Mar 12 15:46:32 2001 Delivered-To: freebsd-current@freebsd.org Received: from femail1.rdc1.on.home.com (femail1.rdc1.on.home.com [24.2.9.88]) by hub.freebsd.org (Postfix) with ESMTP id EB96837B719 for ; Mon, 12 Mar 2001 15:46:17 -0800 (PST) (envelope-from james@ehlo.com) Received: from cr237535-a.bloor1.on.wave.home.com ([24.157.24.3]) by femail1.rdc1.on.home.com (InterMail vM.4.01.03.00 201-229-121) with ESMTP id <20010312234457.TVPA14622.femail1.rdc1.on.home.com@cr237535-a.bloor1.on.wave.home.com>; Mon, 12 Mar 2001 15:44:57 -0800 Received: from james by cr237535-a.bloor1.on.wave.home.com with local (Exim 3.15 #1) id 14cc12-0006eJ-00; Mon, 12 Mar 2001 18:46:16 -0500 Date: Mon, 12 Mar 2001 18:46:16 -0500 From: James FitzGibbon To: KUROSAWA Takahiro , Daniel Eischen Cc: current@freebsd.org Subject: Fixed - pthread altsigstack problem Message-ID: <20010312184616.A25098@ehlo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.4i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Both of the patches below fix the problem mentioned in PR bin/25110. The first one fixes it inside of kern_fork.c and would appear to apply the corrective behaviour regardless of whether the process uses libc_r or not. The second patch fixes the problem inside of uthread_fork.c. Whether the first approach imposes an extra cost on non-threaded applications I'm not kernel-experienced enough to say, but hopefully between two of you gents you can decide which is the better fix to apply. As I mentioned in my original post, this is a bug that we are experiencing in 4.3-BETA, so if this could make it into 4.3-RELEASE it would be of great help. One note regarding the second (libc_r) patch: the reference to __sys_sigaltstack needs to be changed to _thread_sys_sigaltstack in order to prevent undefined symbols on 4.x systems. Patch #1 (kernel fix): --- kern_fork.c.orig Sat Mar 10 12:17:40 2001 +++ kern_fork.c Sat Mar 10 12:20:39 2001 @@ -434,7 +434,7 @@ * Preserve some more flags in subprocess. P_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) Patch #2 (libc_r fix): --- uthread_fork.c 2001/01/24 13:03:33 1.21 +++ uthread_fork.c 2001/03/09 17:53:37 @@ -32,6 +32,7 @@ * $FreeBSD: src/lib/libc_r/uthread/uthread_fork.c,v 1.21 2001/01/24 13:03:33 deischen Exp $ */ #include +#include #include #include #include @@ -110,7 +111,16 @@ else if (_pq_init(&_readyq) != 0) { /* Abort this application: */ PANIC("Cannot initialize priority ready queue."); - } else { + } 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"); + /* * Enter a loop to remove all threads other than * the running thread from the thread list: Thanks for the help guys. -- j. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message