[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#174521: libc6: threads on ppc leave zombies when they terminate



Package: libc6
Version: 2.2.5-11.2
Severity: important

On powerpc, when threads terminate, they leave behind zombies. This
renders maradns and other programs that have "safety brakes" to keep
them from spawning too many threads unusable, limits the number of
threads that any process can create during its lifetime (even if it
never has more than a few at any one time), and can lead to a denial of
service when a long-running threaded process hits the process limit.

I've observed this in mozilla, maradns, and xmms, always on powerpc and
never on other architectures (that I have access to). I'm not aware of
any pthreaded programs that don't do this, so I've concluded that it's
likely to be a libc bug, not a programming error in the various
programs.

Ways to reproduce:
 1 - sample code below
 2 - run mozilla, open some new windows, then close them again
 3 - run xmms, play a file, hit stop
 4 - launch maradns, perform some recursive queries

Here is some example code. On i386 and sparc, it dosen't cause zombies,
but on ppc, it generates zombies. (I'm not confident that my sample code
is completely correct, as I'm not familiar with pthreads, but it does
demonstrate the same problem I've seen in other programs.)


--- cut ---

#include <pthread.h>
#include <errno.h>

#define HOW_MANY_THREADS 10

void threadguts(void *d) {

	int i;

	printf("Thread %i spawned.\n", (int *) d);
	for (i = 0; i < 3; i++) {
		printf("Thread %i doing stuff.\n", (int *) d);
	}

	pthread_exit(0);

}

/* Make a few threads that do stuff, then die. */
int main() {
	pthread_t thread[HOW_MANY_THREADS];
	pthread_attr_t attr;
	void * s;
	int i;
	int e;

	pthread_attr_init(&attr);

	
	for (i = 0; i < HOW_MANY_THREADS; i++) {
		printf("Spawning thread %i\n", i);
		if (e = pthread_create(&thread[i], &attr, (void *) threadguts, (void *) i)) {
			//perror("pthread_create:");
			printf("pthread_create: %s\n", strerror(e));
		}
	}

	/* Make sure they're dead. */
	for (i = 0; i < HOW_MANY_THREADS; i++) {
		printf("Waiting to join thread %i\n", i);
		if (pthread_join(thread[i], NULL)) {
			printf("Can't join thread %i\n", i);
		} else {
			printf("Joined thread %i\n", i);
		}
	}

	pthread_attr_destroy(&attr);


	/* This won't work if too many threads were created - it will
	   be unable to fork
	 */
	system("/bin/ps | grep defunct");

	return 0;

}

--- cut ---


-- System Information
Debian Release: 3.0
Architecture: powerpc
Kernel: Linux badkey.waoki.org 2.4.19-ben0 #1 Mon Aug 5 19:11:44 MDT 2002 ppc
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8

-- 
William Aoki     waoki@umnh.utah.edu       /"\  ASCII Ribbon Campaign
B1FB C169 C7A6 238B 280B  <- key change    \ /  No HTML in mail or news!
99AF A093 29AE 0AE1 9734   prev. expired    X
                                           / \



Reply to: