i386/79772: Setting thread stacksize to PTHREAD_STACK_MIN disables
thread creation
Bill Middleton
flashdict at gmail.com
Sun Apr 10 16:50:22 PDT 2005
>Number: 79772
>Category: i386
>Synopsis: Setting thread stacksize to PTHREAD_STACK_MIN disables thread creation
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-i386
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sun Apr 10 23:50:21 GMT 2005
>Closed-Date:
>Last-Modified:
>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 at 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:
>Unformatted:
More information about the freebsd-i386
mailing list