Bug 114379 - crash while calling pthread_cancel when creating more then 255 threads
Summary: crash while calling pthread_cancel when creating more then 255 threads
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
(Show other bugs)
Version: 9
Hardware: i686 Linux
medium
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-01-27 14:36 UTC by Yuval Carmel
Modified: 2016-11-24 15:17 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-01-28 17:07:23 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description Yuval Carmel 2004-01-27 14:36:11 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET 
CLR 1.1.4322)

Description of problem:
The following program crash when creating more then 254 threads.
When using LD_ASSUME_KERNEL=2.2.5 the program works fine.

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/errno.h>

void * sleeping(void * arg)
{
	sleep(1000);
	return 0;
}

int main(int argc, char *argv[])
{
	int i, j, rc, num_threads;
	pthread_t *tid;

	num_threads = atoi(argv[1]);

	tid = (pthread_t *)malloc(num_threads * sizeof(pthread_t));
	
	for ( i = 0; i < num_threads; i++)
	{
        	rc = pthread_create(&tid[i], NULL, sleeping, (void *)
0);
		if(rc == EAGAIN)
			break;
	}

	printf("%d", i);

	for(j = 0; j < i; j++)
		pthread_cancel(tid[j]);	
		 
	exit(0);	
}


Version-Release number of selected component (if applicable):
kernel-2.4.20-8

How reproducible:
Always

Steps to Reproduce:
1.compile under 2.4.18-14 (RH8)
2.run the program under 2.4.20 (RH9) and it will crash
3.
    

Actual Results:  crash

Additional info:

Comment 1 Jakub Jelinek 2004-01-28 17:07:23 UTC
Please note that the default thread stack size is usually 8M or 10M.
You can easily do the math.  Default thread size on IA-32 is ulimit -s
value, unless it is unlimited, in which case it is 8MB.
I can run (on FC1) up to 305 threads without tweaking thread stack sizes.
They can be tweaked either by running the program with different
ulimit -s, or through pthread_attr_{setstack,setstacksize}.
Hope this helps.


Note You need to log in before you can comment on or make changes to this bug.