From nobody@FreeBSD.org  Sun Apr 10 23:49:22 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id D8C7616A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 10 Apr 2005 23:49:22 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id BD27C43D4C
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 10 Apr 2005 23:49:22 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j3ANnMvF031859
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 10 Apr 2005 23:49:22 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j3ANnMEJ031857;
	Sun, 10 Apr 2005 23:49:22 GMT
	(envelope-from nobody)
Message-Id: <200504102349.j3ANnMEJ031857@www.freebsd.org>
Date: Sun, 10 Apr 2005 23:49:22 GMT
From: Bill Middleton <flashdict@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Setting thread stacksize to PTHREAD_STACK_MIN disables thread creation
X-Send-Pr-Version: www-2.3

>Number:         79772
>Category:       i386
>Synopsis:       Setting thread stacksize to PTHREAD_STACK_MIN disables thread creation
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    davidxu
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 10 23:50:21 GMT 2005
>Closed-Date:    Fri Apr 22 11:51:04 GMT 2005
>Last-Modified:  Fri Apr 22 11:51:04 GMT 2005
>Originator:     Bill Middleton
>Release:        6.0-CURRENT
>Organization:
>Environment:
FreeBSD myhostname.com 6.0-CURRENT FreeBSD 6.0-CURRENT #0: Wed Apr  6 02:41:00 CEST 2005     flashdict@gmail.com:/u2/freebsd/src/sys/i386/compile/MYKERNEL  i386

>Description:
Setting stacksize to PTHREAD_STACK_MIN disables new thread creation with EAGAIN and strerror: Resource temporarily unavailable

This when linked against libthr or libpthread. libc_r works ok.
>How-To-Repeat:
Compile the following C program and link against each of the three libs.

void thread_main (void *arg)
{
        sleep (10);
}

int main () {
        static pthread_t t1,t2;
        static pthread_attr_t attr;
        int ret;
        size_t mysize;
        ret = pthread_attr_init (&attr);
        ret = pthread_attr_getstacksize (&attr, &mysize);
        printf("Current stacksize is %d\n",mysize);
        printf("Starting a new thread\n");
        pthread_create (&t1, &attr, thread_main, NULL);
        if(ret == 0)
                printf("Thread created ok\n");
        printf("Setting stacksize to PTHREAD_STACK_MIN: %d\n",PTHREAD_STACK_MIN);
        ret = pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
        if(ret == 0)
                printf("Stacksize changed ok\n");
        else
                printf("Couldn't set stacksize: %s",strerror (ret));
        ret = pthread_attr_getstacksize (&attr, &mysize);
        printf("New stacksize is %d\n",mysize);
        printf("Starting another new thread\n");
        ret = pthread_create (&t2, &attr, thread_main, NULL);
        if(ret == 0)
                printf("Thread created ok\n");
        else
                printf("Couldn't create thread: %s\n",strerror (ret));
}

>Fix:
      Heh.  I wish.
>Release-Note:
>Audit-Trail:

From: Bill Middleton <flashdict@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org, flashdict@gmail.com
Cc:  
Subject: Re: i386/79772: Setting thread stacksize to PTHREAD_STACK_MIN disables
 thread creation
Date: Mon, 11 Apr 2005 17:19:07 +0200

 I have been informed by David Xu that this is now fixed in CURRENT.
 
 Bill Middleton
Responsible-Changed-From-To: freebsd-i386->davidxu 
Responsible-Changed-By: arved 
Responsible-Changed-When: Fri Apr 22 11:06:09 GMT 2005 
Responsible-Changed-Why:  
Over to davidxu to decide if this PR can be closed 

http://www.freebsd.org/cgi/query-pr.cgi?pr=79772 
State-Changed-From-To: open->closed 
State-Changed-By: arved 
State-Changed-When: Fri Apr 22 11:50:45 GMT 2005 
State-Changed-Why:  
davidxu says this is fixed 

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