mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] [3d RESEND] de_thread()
@ 2002-10-16 14:32 Oleg Nesterov
  0 siblings, 0 replies; only message in thread
From: Oleg Nesterov @ 2002-10-16 14:32 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar

Hello.

On Thu, 10 Oct 2002, Oleg Nesterov wrote:
> 
> Suppose process P in thread group was cloned _without_
> CLONE_DETACHED flag. Then another thread, group_leader
> for simplicity, does exec and calls de_thread(). It kills
> P via _broadcast_thread_group(). While doing do_exit(),
> P skips release_task(), because its exit_signal != -1,
> and becomes TASK_ZOMBIE.
>
> Then leader calls schedule() with TASK_UNINTERRUPTIBLE
> in while(oldsig->count > 1) {...} and sleeps forever,
> because nobody can do wake_up_process(sig->group_exit_task).
>

This program should hang leaving task in D state.

#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <asm/unistd.h>

#define CLONE_SIGHAND	0x00000800
#define CLONE_THREAD	0x00010000

#define	__NR_sys_clone	__NR_clone

static inline _syscall2(int,sys_clone, int,flag, void*,stack)

int main(void)
{
	static char stack[1024];
	int pid = sys_clone(CLONE_THREAD | CLONE_SIGHAND | SIGCHLD, stack);

	if (pid < 0) {
		printf("ERR!! clone: %s.\n", strerror(errno));
		return -1;
	}

	if (pid == 0) _exit(0);

	execlp("echo", "echo", "Should not happen.", 0);
	printf("ERR!! exec: %s.\n", strerror(errno));

	return 0;
}

Oleg.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-16 14:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-16 14:32 [BUG] [3d RESEND] de_thread() Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®