*[prev in list <?l=user-mode-linux-user&m=109846682627300&w=2>] [next in list <?l=user-mode-linux-user&m=109846924009334&w=2>] [prev in thread <?l=user-mode-linux-user&m=109846488813795&w=2>] [next in thread <?l=user-mode-linux-user&m=109846985005560&w=2>] *
*
List:       user-mode-linux-user <?l=user-mode-linux-user&r=1&w=2>
Subject:    Re: [uml-user] host-skas3-2.6.9-rc4-v6.patch + vanilla 2.6.9 => zombie UMLs <?t=109840687100002&r=1&w=2>
From:       Gerd Knorr <kraxel () bytesex ! org> <?a=97465840700003&r=1&w=2>
Date:       2004-10-22 17:01:33 <?l=user-mode-linux-user&r=1&w=2&b=200410>
Message-ID: <20041022170133.GA8067 () bytesex> <?i=<20041022170133.GA8067%20()%20bytesex>>
[Download message RAW <?l=user-mode-linux-user&m=109846839005849&q=raw>]*

> > is this a known issue?
> Yes, sadly - it started IIRC since -rc2, and is due to a change in mainline. I 
> was not testing it, while Gerd Knorr, who ported the SKAS patch, reported it 
> to LKML. Nobody answered him, so this is the situation.
> 
> > If I use the bare vanilla 2.6.9 kernel with the skas3-patch above,
> > everything compiles fine and it boots w/o any problems. Running several
> > UMLs works good, too.

> > But the UML-tasks don't halt proper. If I shutdown a UML, the UML task
> > is still in my process table. And if I kill it, it still remain as a zombie
> > task allocating my file systems.

Trying again, seems nobody noticed the first mail ...

The patch below fixes it for me.  Tested skas only.  Reportly tt has
some issues as well and likely needs trace_cont=1 on some of the
os_kill_process() calls as well.

Background: the -rc2 patch introduces a new process state for processes
being stopped due to being traced, older kernels had the same state for
processes being stopped due to being traced and being stopped due to
SIGSTOP.  That change has the effect that the process doesn't see the
SIGKILL instantly when being ptrace-stopped, you have to PTRACE_CONT it
(and first send the SIGKILL and then PTRACE_CONT to avoid a race).

  Gerd

Index: linux-uml-2.6.9/arch/um/include/os.h
===================================================================
--- linux-uml-2.6.9.orig/arch/um/include/os.h	2004-10-20 10:56:02.000000000 +0200
+++ linux-uml-2.6.9/arch/um/include/os.h	2004-10-20 16:58:00.000000000 +0200
@@ -156,7 +156,7 @@ extern int os_lock_file(int fd, int excl
 extern unsigned long os_process_pc(int pid);
 extern int os_process_parent(int pid);
 extern void os_stop_process(int pid);
-extern void os_kill_process(int pid, int reap_child);
+extern void os_kill_process(int pid, int reap_child, int trace_cont);
 extern void os_usr1_process(int pid);
 extern int os_getpid(void);
 
Index: linux-uml-2.6.9/arch/um/os-Linux/process.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/os-Linux/process.c	2004-10-20 10:55:52.000000000 +0200
+++ linux-uml-2.6.9/arch/um/os-Linux/process.c	2004-10-20 17:16:58.000000000 +0200
@@ -10,6 +10,7 @@
 #include <linux/unistd.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
+#include <sys/ptrace.h>
 #include "os.h"
 #include "user.h"
 #include "user_util.h"
@@ -86,12 +87,13 @@ void os_stop_process(int pid)
 	kill(pid, SIGSTOP);
 }
 
-void os_kill_process(int pid, int reap_child)
+void os_kill_process(int pid, int reap_child, int trace_cont)
 {
 	kill(pid, SIGKILL);
-	if(reap_child)
+	if (trace_cont)
+		ptrace(PTRACE_CONT, pid, NULL, NULL);
+	if (reap_child)
 		CATCH_EINTR(waitpid(pid, NULL, 0));
-		
 }
 
 void os_usr1_process(int pid)
Index: linux-uml-2.6.9/arch/um/drivers/port_kern.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/drivers/port_kern.c	2004-10-20 10:55:44.000000000 +0200
+++ linux-uml-2.6.9/arch/um/drivers/port_kern.c	2004-10-20 14:36:10.000000000 +0200
@@ -112,7 +112,7 @@ static int port_accept(struct port_list 
  out_close:
 	os_close_file(fd);
 	if(pid != -1) 
-		os_kill_process(pid, 1);
+		os_kill_process(pid, 1, 0);
  out:
 	return(ret);
 } 
@@ -262,9 +262,9 @@ void port_remove_dev(void *d)
 	struct port_dev *dev = d;
 
 	if(dev->helper_pid != -1)
-		os_kill_process(dev->helper_pid, 0);
+		os_kill_process(dev->helper_pid, 0, 0);
 	if(dev->telnetd_pid != -1)
-		os_kill_process(dev->telnetd_pid, 1);
+		os_kill_process(dev->telnetd_pid, 1, 0);
 	dev->helper_pid = -1;
 	dev->telnetd_pid = -1;
 }
Index: linux-uml-2.6.9/arch/um/drivers/ubd_kern.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/drivers/ubd_kern.c	2004-10-20 10:56:28.000000000 +0200
+++ linux-uml-2.6.9/arch/um/drivers/ubd_kern.c	2004-10-20 14:36:49.000000000 +0200
@@ -470,7 +470,7 @@ static int io_pid = -1;
 void kill_io_thread(void)
 {
 	if(io_pid != -1) 
-		os_kill_process(io_pid, 1);
+		os_kill_process(io_pid, 1, 0);
 }
 
 __uml_exitcall(kill_io_thread);
Index: linux-uml-2.6.9/arch/um/drivers/line.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/drivers/line.c	2004-10-20 11:46:34.000000000 +0200
+++ linux-uml-2.6.9/arch/um/drivers/line.c	2004-10-20 14:34:38.000000000 +0200
@@ -638,7 +638,7 @@ static void winch_cleanup(void)
 			os_close_file(winch->fd);
 		}
 		if(winch->pid != -1) 
-			os_kill_process(winch->pid, 1);
+			os_kill_process(winch->pid, 1, 0);
 	}
 }
 __uml_exitcall(winch_cleanup);
Index: linux-uml-2.6.9/arch/um/kernel/skas/process.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/kernel/skas/process.c	2004-10-20 11:46:32.000000000 +0200
+++ linux-uml-2.6.9/arch/um/kernel/skas/process.c	2004-10-20 16:33:16.000000000 +0200
@@ -400,7 +400,7 @@ void switch_mm_skas(int mm_fd)
 void kill_off_processes_skas(void)
 {
 #warning need to loop over userspace_pids in kill_off_processes_skas
-	os_kill_process(userspace_pid[0], 1);
+	os_kill_process(userspace_pid[0], 1, 1);
 }
 
 void init_registers(int pid)
Index: linux-uml-2.6.9/arch/um/kernel/process.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/kernel/process.c	2004-10-20 10:56:58.000000000 +0200
+++ linux-uml-2.6.9/arch/um/kernel/process.c	2004-10-20 16:54:56.000000000 +0200
@@ -141,7 +141,7 @@ static int ptrace_child(void *arg)
 
 	if(ptrace(PTRACE_TRACEME, 0, 0, 0) < 0){
 		perror("ptrace");
-		os_kill_process(pid, 0);
+		os_kill_process(pid, 0, 0);
 	}
 	os_stop_process(pid);
 	_exit(os_getpid() == pid);
Index: linux-uml-2.6.9/arch/um/kernel/helper.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/kernel/helper.c	2004-10-20 10:56:28.000000000 +0200
+++ linux-uml-2.6.9/arch/um/kernel/helper.c	2004-10-20 16:38:22.000000000 +0200
@@ -45,7 +45,7 @@ static int helper_child(void *arg)
 	errval = errno;
 	printk("execvp of '%s' failed - errno = %d\n", argv[0] <#0>, errno);
 	os_write_file(data->fd, &errval, sizeof(errval));
-	os_kill_process(os_getpid(), 0);
+	os_kill_process(os_getpid(), 0, 0);
 	return(0);
 }
 
@@ -106,7 +106,7 @@ int run_helper(void (*pre_exec)(void *),
 	return(pid);
 
  out_kill:
-	os_kill_process(pid, 1);
+	os_kill_process(pid, 1, 0);
  out_close:
 	os_close_file(fds[0] <#0>);
 	os_close_file(fds[1] <#1>);
Index: linux-uml-2.6.9/arch/um/kernel/tt/process_kern.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/kernel/tt/process_kern.c	2004-10-20 10:56:57.000000000 +0200
+++ linux-uml-2.6.9/arch/um/kernel/tt/process_kern.c	2004-10-20 16:31:31.000000000 +0200
@@ -66,7 +66,7 @@ void *switch_to_tt(void *prev, void *nex
 
 	reading = 1;
 	if((from->state == TASK_ZOMBIE) || (from->state == TASK_DEAD))
-		os_kill_process(os_getpid(), 0);
+		os_kill_process(os_getpid(), 0, 0);
 
 	err = os_read_file(from->thread.mode.tt.switch_pipe[0] <#0>, &c, sizeof(c));
 	if(err != sizeof(c))
@@ -82,7 +82,7 @@ void *switch_to_tt(void *prev, void *nex
 	prev_sched = current->thread.prev_sched;
 	if((prev_sched->state == TASK_ZOMBIE) ||
 	   (prev_sched->state == TASK_DEAD))
-		os_kill_process(prev_sched->thread.mode.tt.extern_pid, 1);
+		os_kill_process(prev_sched->thread.mode.tt.extern_pid, 1, 1);
 
 	/* This works around a nasty race with 'jail'.  If we are switching
 	 * between two threads of a threaded app and the incoming process 
@@ -119,7 +119,7 @@ void release_thread_tt(struct task_struc
 	int pid = task->thread.mode.tt.extern_pid;
 
 	if(os_getpid() != pid)
-		os_kill_process(pid, 0);
+		os_kill_process(pid, 0, 0);
 }
 
 void exit_thread_tt(void)
@@ -331,10 +331,10 @@ void kill_off_processes_tt(void)
 	me = os_getpid();
         for_each_process(p){
 		if(p->thread.mode.tt.extern_pid != me) 
-			os_kill_process(p->thread.mode.tt.extern_pid, 0);
+			os_kill_process(p->thread.mode.tt.extern_pid, 0, 0);
 	}
 	if(init_task.thread.mode.tt.extern_pid != me) 
-		os_kill_process(init_task.thread.mode.tt.extern_pid, 0);
+		os_kill_process(init_task.thread.mode.tt.extern_pid, 0, 0);
 }
 
 void initial_thread_cb_tt(void (*proc)(void *), void *arg)
Index: linux-uml-2.6.9/arch/um/drivers/xterm.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/drivers/xterm.c	2004-10-20 11:46:34.000000000 +0200
+++ linux-uml-2.6.9/arch/um/drivers/xterm.c	2004-10-20 17:01:27.000000000 +0200
@@ -168,10 +168,10 @@ void xterm_close(int fd, void *d)
 	struct xterm_chan *data = d;
 	
 	if(data->pid != -1) 
-		os_kill_process(data->pid, 1);
+		os_kill_process(data->pid, 1, 0);
 	data->pid = -1;
 	if(data->helper_pid != -1) 
-		os_kill_process(data->helper_pid, 0);
+		os_kill_process(data->helper_pid, 0, 0);
 	data->helper_pid = -1;
 	os_close_file(fd);
 }
Index: linux-uml-2.6.9/arch/um/kernel/sigio_user.c
===================================================================
--- linux-uml-2.6.9.orig/arch/um/kernel/sigio_user.c	2004-10-20 10:57:05.000000000 +0200
+++ linux-uml-2.6.9/arch/um/kernel/sigio_user.c	2004-10-20 16:58:56.000000000 +0200
@@ -259,7 +259,7 @@ static void update_thread(void)
  fail:
 	sigio_lock();
 	if(write_sigio_pid != -1) 
-		os_kill_process(write_sigio_pid, 1);
+		os_kill_process(write_sigio_pid, 1, 0);
 	write_sigio_pid = -1;
 	os_close_file(sigio_private[0] <#0>);
 	os_close_file(sigio_private[1] <#1>);
@@ -386,7 +386,7 @@ void write_sigio_workaround(void)
 	return;
 
  out_kill:
-	os_kill_process(write_sigio_pid, 1);
+	os_kill_process(write_sigio_pid, 1, 0);
 	write_sigio_pid = -1;
  out_close2:
 	os_close_file(sigio_private[0] <#0>);
@@ -419,7 +419,7 @@ int read_sigio_fd(int fd)
 static void sigio_cleanup(void)
 {
 	if(write_sigio_pid != -1)
-		os_kill_process(write_sigio_pid, 1);
+		os_kill_process(write_sigio_pid, 1, 0);
 }
 
 __uml_exitcall(sigio_cleanup);


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
User-mode-linux-user mailing list
User-mode-linux-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user
*[prev in list <?l=user-mode-linux-user&m=109846682627300&w=2>] [next in list <?l=user-mode-linux-user&m=109846924009334&w=2>] [prev in thread <?l=user-mode-linux-user&m=109846488813795&w=2>] [next in thread <?l=user-mode-linux-user&m=109846985005560&w=2>] *


Configure <?q=configure> | About MARC <?q=about> | Support MARC
<?q=about#Begware> | Got a list to add?
<mailto:webguy@theaimsgroup.com?subject=Add a list to MARC> | 10East
<http://www.10East.com/> is Hiring!
<http://www.10East.com/?sect=employment>

