public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Roland McGrath <roland@redhat.com>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Michael Kerrisk <mtk-lkml@gmx.net>,
	Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH] fix de_thread() vs do_coredump() deadlock
Date: Tue, 11 Apr 2006 16:03:26 +0400	[thread overview]
Message-ID: <20060411120326.GA84@oleg> (raw)
In-Reply-To: <20060411072722.0953A1809BB@magilla.sf.frob.com>

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.


  parent reply	other threads:[~2006-04-11  8:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-13 16:50 [PATCH] fix de_thread() vs do_coredump() deadlock Oleg Nesterov
2006-04-10  1:36 ` Roland McGrath
2006-04-10 17:43   ` Oleg Nesterov
2006-04-11  7:27     ` Roland McGrath
2006-04-11 11:47       ` Oleg Nesterov
2006-04-11  9:10         ` Roland McGrath
2006-04-11 12:03       ` Oleg Nesterov [this message]
2006-04-10 21:40   ` Oleg Nesterov
2006-04-11  8:01     ` Roland McGrath
2006-04-11 13:13       ` Oleg Nesterov
2006-04-11  9:49         ` Roland McGrath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060411120326.GA84@oleg \
    --to=oleg@tv-sign.ru \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mtk-lkml@gmx.net \
    --cc=roland@redhat.com \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox