threads/101323: fork(2) in threaded programs broken.

Poul-Henning Kamp phk at critter.freebsd.dk
Thu Aug 3 17:40:29 UTC 2006


>Number:         101323
>Category:       threads
>Synopsis:       fork(2) in threaded programs broken.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-threads
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Aug 03 17:40:15 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Poul-Henning Kamp
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD critter.freebsd.dk 7.0-CURRENT FreeBSD 7.0-CURRENT #5: Wed Jul 5 22:14:32 UTC 2006 root at critter.freebsd.dk:/critter/obj/critter/src/sys/TP41P i386


>Description:

	Forking a threaded process and starting a thread in the
	child process does not work.

	Tested on -current and releng_6 and both fails with more or
	less the same error message:

	Fatal error 'mutex is on list' at line 540 in file
	    /usr/src/lib/libpthread/thread/thr_mutex.c (errno = 0)

>How-To-Repeat:

	#include <pthread.h>
	#include <stdio.h>

	void *
	thr_sleeper(void *arg)
	{

		(void)arg;
		while (1) {
			printf("%d\n", getpid());
			sleep (1);
		}
	}

	int
	main(int argc, char **argv)
	{
		pthread_t t1, t2;

		(void)argc;
		(void)argv;
		pthread_create(&t1, NULL, thr_sleeper, NULL);
		if (!fork()) {
			pthread_create(&t2, NULL, thr_sleeper, NULL);
			while(1)
				sleep(1);
		}
		while(1)
			sleep(1);
	}

>Fix:

	


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-threads mailing list