From das@HAL9000.homeunix.com  Wed Dec 18 00:12:50 2002
Return-Path: <das@HAL9000.homeunix.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id B696C37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Dec 2002 00:12:50 -0800 (PST)
Received: from HAL9000.homeunix.com (12-232-220-15.client.attbi.com [12.232.220.15])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 1484543ED1
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Dec 2002 00:12:45 -0800 (PST)
	(envelope-from das@HAL9000.homeunix.com)
Received: from HAL9000.homeunix.com (localhost [127.0.0.1])
	by HAL9000.homeunix.com (8.12.6/8.12.5) with ESMTP id gBI8CcnZ046437;
	Wed, 18 Dec 2002 00:12:38 -0800 (PST)
	(envelope-from das@HAL9000.homeunix.com)
Received: (from das@localhost)
	by HAL9000.homeunix.com (8.12.6/8.12.5/Submit) id gBI8CbsN046436;
	Wed, 18 Dec 2002 00:12:37 -0800 (PST)
	(envelope-from das)
Message-Id: <200212180812.gBI8CbsN046436@HAL9000.homeunix.com>
Date: Wed, 18 Dec 2002 00:12:37 -0800 (PST)
From: David Schultz <dschultz@uclink.Berkeley.EDU>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Varshavchick Alexander <alex@metrocom.ru>
Subject: apps linked against pthreads break when KVA_PAGES changes
X-Send-Pr-Version: 3.113

>Number:         46341
>Category:       bin
>Synopsis:       apps linked against pthreads break when KVA_PAGES changes
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    das
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Dec 18 00:20:01 PST 2002
>Closed-Date:    Mon Feb 24 15:29:09 PST 2003
>Last-Modified:  Mon Feb 24 15:29:09 PST 2003
>Originator:     David Schultz
>Release:        4.7-STABLE
>Organization:
>Environment:
>Description:
Revision 1.35 of src/lib/libc_r/uthread/uthread_init.c was supposed to
make applications linked against libc_r continue to work without
recompiling after changing KVA_PAGES.  The following patches fill in a
detail to make the feature actually work.  For details, see the
thread on hackers@ with subject 'maxusers and random system freezes'.

(This problem was fixed in -CURRENT, perhaps by accident, when the
stack allocation code was substantially reorganized.)
>How-To-Repeat:
>Fix:
Tested-by: Varshavchick Alexander <alex@metrocom.ru>

Index: uthread/uthread_init.c
===================================================================
RCS file: /home/ncvs/src/lib/libc_r/uthread/uthread_init.c,v
retrieving revision 1.23.2.10
diff -u -r1.23.2.10 uthread_init.c
--- uthread/uthread_init.c	2002/10/22 14:44:03	1.23.2.10
+++ uthread/uthread_init.c	2002/12/06 13:41:06
@@ -245,6 +245,8 @@
 		len = sizeof (int);
 		if (sysctl(mib, 2, &_usrstack, &len, NULL, 0) == -1)
 			_usrstack = (void *)USRSTACK;
+		_next_stack = _usrstack - PTHREAD_STACK_INITIAL -
+		    PTHREAD_STACK_DEFAULT - (2 * PTHREAD_STACK_GUARD);
 		/*
 		 * Create a red zone below the main stack.  All other stacks are
 		 * constrained to a maximum size by the paramters passed to
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->das 
Responsible-Changed-By: das 
Responsible-Changed-When: Mon Feb 24 01:19:56 PST 2003 
Responsible-Changed-Why:  
Over to me.  I can deal with my own PRs now. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=46341 
State-Changed-From-To: open->closed 
State-Changed-By: das 
State-Changed-When: Mon Feb 24 15:28:23 PST 2003 
State-Changed-Why:  
Committed.  Thanks, self! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=46341 
>Unformatted:
