Re: [PATCH] fix de_thread() vs do_coredump() deadlock

From: Oleg Nesterov
Date: Tue Apr 11 2006 - 04:06:31 EST


On 04/11, Roland McGrath wrote:
>
> > So, de_thread() sets SIGNAL_GROUP_EXEC and sends SIGKILL to other thereads.
> >
> > Sub-thread receives the signal, and calls get_signal_to_deliver->do_group_exit.
> > do_group_exit() calls zap_other_threads(SIGNAL_GROUP_EXIT) because there is no
> > SIGNAL_GROUP_EXIT set. zap_other_threads() notices SIGNAL_GROUP_EXEC, wakes up
> > execer, and changes ->signal->flags to SIGNAL_GROUP_EXIT.
> >
> > de_thread() re-locks sighand, sees !SIGNAL_GROUP_EXEC and goes to 'dying:'.
>
> That is what I intend. The exec'ing thread backs out and processes its SIGKILL.
> It sounds like you are calling this scenario a problem, but I don't know why.

Ok, here is the test:

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

static void *tfunc(void *arg)
{
pause();
return NULL;
}

int main(int argc, const char *argv[])
{
pthread_t thread;

if (!argv[0]) {
printf("--------- SUCCESS ----------\n");
exit(0);
}

if (pthread_create(&thread, NULL, tfunc, NULL)) {
perror ("pthread_create");
exit (1);
}

execl("/proc/self/exe", NULL);

return pause();
}


$ ./test
--------- SUCCESS ----------

With this patch applied I have:

$ ./test
Killed

Oleg.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/