threads/119920: fork broken in libpthread
Julian Elischer
julian at elischer.org
Thu Jan 31 11:13:13 PST 2008
Landon Fuller wrote:
>
> On Jan 31, 2008, at 10:44, Julian Elischer wrote:
>
>> the releng 6 and releng 7 versions of this patch are at:
>>
>> http://www.freebsd.org/~julian/kse-6.diff
>>
>> and
>>
>> http://www.freebsd.org/~julian/kse-7.diff
>>
>>
>> but the one for 7 is just speculative.
>>
>> I don't have a 7.x system to test.
>>
>>
>> Landon, what is your test case?
>>
>
> Inlined below. On our 8-core 6.3 system without this patch, the fork()
> threads wedge and spin in <2 minutes. With the patch, works as expected.
>
> #include <sys/types.h>
> #include <unistd.h>
> #include <pthread.h>
>
> void *forker (void *arg) {
> while (1) {
> pid_t pid = fork();
> if (pid == 0) {
> exit(0);
> } else if (pid > 0) {
> int status;
> waitpid(pid, &status, 0);
> } else {
> printf("Fork failed\n");
> abort();
> }
> }
> }
>
> int main(void) {
> int i = 0;
> for (i = 0; i < 4; i++) {
> pthread_t thr;
> pthread_create(&thr, NULL, forker, NULL);
> pthread_detach(thr);
> }
>
> while(1)
> sleep(1000);
> }
great..
is there anyone with a 7.0 MP system, that can confirm that this
happens in 7 and that the patch (above) fixes it?
More information about the freebsd-threads
mailing list