linux-um archives
 help / color / mirror / Atom feed
* [uml-devel] Kernel panic: handle_trap - failed to wait at end of syscall, errno = 4, status = 1151
@ 2004-06-19  0:19 Christopher S. Aker
  2004-06-19 17:39 ` Jeff Dike
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher S. Aker @ 2004-06-19  0:19 UTC (permalink / raw)
  To: uml-devel

Hey all,

I just had a user experience this panic:

Kernel panic: handle_trap - failed to wait at end of syscall, errno = 4, status =
1151

UML: 2.6.5 vanilla + uml-patch-2.6.4-1
HOST: 2.6.4 + SKAS patch

From arch/um/kernel/skas/process.c:

        err = waitpid(pid, &status, WUNTRACED);
        if((err < 0) || !WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
                panic("handle_trap - failed to wait at end of syscall, "
                      "errno = %d, status = %d\n", errno, status);

Any thoughts?  I've never seen this before...

-Chris



-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [uml-devel] Kernel panic: handle_trap - failed to wait at end of syscall, errno = 4, status = 1151
  2004-06-19  0:19 [uml-devel] Kernel panic: handle_trap - failed to wait at end of syscall, errno = 4, status = 1151 Christopher S. Aker
@ 2004-06-19 17:39 ` Jeff Dike
  2004-06-22 13:18   ` Joe Marzot
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Dike @ 2004-06-19 17:39 UTC (permalink / raw)
  To: Christopher S. Aker; +Cc: uml-devel

On Fri, Jun 18, 2004 at 07:19:57PM -0500, Christopher S. Aker wrote:
> Kernel panic: handle_trap - failed to wait at end of syscall, errno = 4, status =
> 1151
> 
>         err = waitpid(pid, &status, WUNTRACED);
>         if((err < 0) || !WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
>                 panic("handle_trap - failed to wait at end of syscall, "
>                       "errno = %d, status = %d\n", errno, status);

Easy diagnosis - errno 4 is EINTR, this wasn't checking for that and redoing
the wait.

I've been adding EINTR safety in a bit at a time, just hadn't noticed this
yet.

				Jeff


-------------------------------------------------------
This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [uml-devel] Kernel panic: handle_trap - failed to wait at end of syscall, errno = 4, status = 1151
  2004-06-19 17:39 ` Jeff Dike
@ 2004-06-22 13:18   ` Joe Marzot
  2004-06-22 15:43     ` Jeff Dike
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Marzot @ 2004-06-22 13:18 UTC (permalink / raw)
  To: Jeff Dike; +Cc: Christopher S. Aker, uml-devel

would this be something simple like

do {
    err = waitpid(pid, &status, WUNTRACED);
} while ((err < 0) && (errno == EINTR));

strangely I am seeing this error also w/ host 2.4.20-24.8 + 
host-skas3a-2.4.25.patch and 2.4.22+uml_patch-2.4.24-1.

regards, GSM

Jeff Dike wrote:
> On Fri, Jun 18, 2004 at 07:19:57PM -0500, Christopher S. Aker wrote:
> 
>>Kernel panic: handle_trap - failed to wait at end of syscall, errno = 4, status =
>>1151
>>
>>        err = waitpid(pid, &status, WUNTRACED);
>>        if((err < 0) || !WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
>>                panic("handle_trap - failed to wait at end of syscall, "
>>                      "errno = %d, status = %d\n", errno, status);
> 
> 
> Easy diagnosis - errno 4 is EINTR, this wasn't checking for that and redoing
> the wait.
> 
> I've been adding EINTR safety in a bit at a time, just hadn't noticed this
> yet.
> 
> 				Jeff
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by The 2004 JavaOne(SM) Conference
> Learn from the experts at JavaOne(SM), Sun's Worldwide Java Developer
> Conference, June 28 - July 1 at the Moscone Center in San Francisco, CA
> REGISTER AND SAVE! http://java.sun.com/javaone/sf Priority Code NWMGYKND
> _______________________________________________
> User-mode-linux-devel mailing list
> User-mode-linux-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
> 





-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [uml-devel] Kernel panic: handle_trap - failed to wait at end of syscall, errno = 4, status = 1151
  2004-06-22 13:18   ` Joe Marzot
@ 2004-06-22 15:43     ` Jeff Dike
  2004-06-23 18:09       ` [PATCH] The fix for: Re: [uml-devel] Kernel panic: handle_trap - failed to wait at end of syscall, BlaisorBlade
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Dike @ 2004-06-22 15:43 UTC (permalink / raw)
  To: Joe Marzot; +Cc: Christopher S. Aker, uml-devel

On Tue, Jun 22, 2004 at 09:18:42AM -0400, Joe Marzot wrote:
> would this be something simple like
> 
> do {
>    err = waitpid(pid, &status, WUNTRACED);
> } while ((err < 0) && (errno == EINTR));
> 

Yup, it would be that simple.

				Jeff


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] The fix for: Re: [uml-devel] Kernel panic: handle_trap - failed to wait at end of syscall, ...
  2004-06-22 15:43     ` Jeff Dike
@ 2004-06-23 18:09       ` BlaisorBlade
  0 siblings, 0 replies; 5+ messages in thread
From: BlaisorBlade @ 2004-06-23 18:09 UTC (permalink / raw)
  To: Jeff Dike, Joe Marzot; +Cc: Christopher S. Aker, uml-devel

[-- Attachment #1: Type: text/plain, Size: 1466 bytes --]

Alle 17:43, martedì 22 giugno 2004, Jeff Dike ha scritto:
> On Tue, Jun 22, 2004 at 09:18:42AM -0400, Joe Marzot wrote:
> > would this be something simple like
> >
> > do {
> >    err = waitpid(pid, &status, WUNTRACED);
> > } while ((err < 0) && (errno == EINTR));
>
> Yup, it would be that simple.

Since this is needed in so many places (see the attached patch to realize), 
I've decided to write a macro for this:

#define CATCH_EINTR(expr) while ( ((expr) < 0) && errno == EINTR)

I found this to be the more natural way. In some cases it would have been 
useful if CATCH_EINTR were a rvalue, but this could be workarounded, and the 
original form gave more problems (sometimes I had no "err" available, and 
adding it was useless):

#define CATCH_EINTR(err, expr) do { (err) = (expr); } while (((err) < 0) && 
(errno == EINTR))

I also built the attached patch, which adds a few usages of it. If you grep 
for waitpid() you'll find a lot more ones, I just did not catch them all.

Plus the ones for other calls; there is a ton of them; grep your man pages 
with

bzgrep -l EINTR /usr/share/man/man2/* |sed -e 's!.*/!!;s!\.2\.bz2!!'

(use zgrep if needed) to get a raw feeling of how much there are (some of 
these are bogus references, anyway).

I'm going to compile all this, ASAP I'll post the second version which will 
actually compile :-)!

Bye
-- 
Paolo Giarrusso, aka Blaisorblade
Linux registered user n. 292729

[-- Attachment #2: EINTR_safety.patch --]
[-- Type: text/x-diff, Size: 17439 bytes --]

---

 uml-linux-2.6.7-paolo/arch/um/drivers/net_user.c               |    3 +-
 uml-linux-2.6.7-paolo/arch/um/drivers/slip_user.c              |    6 +++--
 uml-linux-2.6.7-paolo/arch/um/drivers/slirp_user.c             |    8 +++----
 uml-linux-2.6.7-paolo/arch/um/include/user_util.h              |    1 
 uml-linux-2.6.7-paolo/arch/um/kernel/frame.c                   |    8 ++++---
 uml-linux-2.6.7-paolo/arch/um/kernel/helper.c                  |    3 +-
 uml-linux-2.6.7-paolo/arch/um/kernel/process.c                 |   11 +++++-----
 uml-linux-2.6.7-paolo/arch/um/kernel/skas/exec_user.c          |    6 +++--
 uml-linux-2.6.7-paolo/arch/um/kernel/skas/process.c            |    6 ++---
 uml-linux-2.6.7-paolo/arch/um/kernel/trap_user.c               |    9 +++++++-
 uml-linux-2.6.7-paolo/arch/um/kernel/tt/exec_user.c            |    9 ++++++--
 uml-linux-2.6.7-paolo/arch/um/kernel/tt/ptproxy/proxy.c        |    4 +--
 uml-linux-2.6.7-paolo/arch/um/kernel/tt/tracer.c               |    4 +--
 uml-linux-2.6.7-paolo/arch/um/kernel/user_util.c               |   10 +++------
 uml-linux-2.6.7-paolo/arch/um/os-Linux/drivers/ethertap_user.c |    4 ++-
 uml-linux-2.6.7-paolo/arch/um/os-Linux/drivers/tuntap_user.c   |    3 +-
 uml-linux-2.6.7-paolo/arch/um/os-Linux/process.c               |    3 +-
 17 files changed, 61 insertions(+), 37 deletions(-)

diff -puN arch/um/kernel/skas/process.c~EINTR_safety arch/um/kernel/skas/process.c
--- uml-linux-2.6.7/arch/um/kernel/skas/process.c~EINTR_safety	2004-06-23 18:28:50.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/kernel/skas/process.c	2004-06-23 19:48:54.000000000 +0200
@@ -81,7 +81,7 @@ static void handle_trap(int pid, union u
 			panic("handle_trap - continuing to end of syscall failed, "
 			      "errno = %d\n", errno);
 
-		err = waitpid(pid, &status, WUNTRACED);
+		CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
 		if((err < 0) || !WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
 			panic("handle_trap - failed to wait at end of syscall, "
 			      "errno = %d, status = %d\n", errno, status);
@@ -121,7 +121,7 @@ void start_userspace(int cpu)
 		panic("start_userspace : clone failed, errno = %d", errno);
 
 	do {
-		n = waitpid(pid, &status, WUNTRACED);
+		CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
 		if(n < 0)
 			panic("start_userspace : wait failed, errno = %d", 
 			      errno);
@@ -154,7 +154,7 @@ void userspace(union uml_pt_regs *regs)
 		panic("userspace - PTRACE_SYSCALL failed, errno = %d\n", 
 		       errno);
 	while(1){
-		err = waitpid(pid, &status, WUNTRACED);
+		CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
 		if(err < 0)
 			panic("userspace - waitpid failed, errno = %d\n", 
 			      errno);
diff -puN arch/um/include/user_util.h~EINTR_safety arch/um/include/user_util.h
--- uml-linux-2.6.7/arch/um/include/user_util.h~EINTR_safety	2004-06-23 18:29:42.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/include/user_util.h	2004-06-23 19:46:19.000000000 +0200
@@ -92,6 +92,7 @@ extern void arch_init_thread(void);
 extern int __raw(int fd, int complain, int now);
 #define raw(fd, complain) __raw((fd), (complain), 1)
 
+#define CATCH_EINTR(expr) while ( ((expr) < 0) && errno == EINTR)
 #endif
 
 /*
diff -puN arch/um/kernel/user_util.c~EINTR_safety arch/um/kernel/user_util.c
--- uml-linux-2.6.7/arch/um/kernel/user_util.c~EINTR_safety	2004-06-23 18:30:03.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/kernel/user_util.c	2004-06-23 20:04:19.000000000 +0200
@@ -81,11 +81,10 @@ int wait_for_stop(int pid, int sig, int 
 	int status, ret;
 
 	while(1){
-		ret = waitpid(pid, &status, WUNTRACED);
+		CATCH_EINTR(ret = waitpid(pid, &status, WUNTRACED));
 		if((ret < 0) ||
 		   !WIFSTOPPED(status) || (WSTOPSIG(status) != sig)){
 			if(ret < 0){
-				if(errno == EINTR) continue;
 				printk("wait failed, errno = %d\n",
 				       errno);
 			}
@@ -125,8 +124,7 @@ int __raw(int fd, int complain, int now)
 	int err;
 	int when;
 
-	while (((err = tcgetattr(fd, &tt)) < 0) && errno == EINTR)
-		;
+	CATCH_EINTR(err = tcgetattr(fd, &tt));
 
 	if (err < 0) {
 		if (complain)
@@ -141,8 +139,8 @@ int __raw(int fd, int complain, int now)
 	else
 		when = TCSADRAIN;
 
-	while (((err = tcsetattr(fd, when, &tt)) < 0) && errno == EINTR)
-		;
+	CATCH_EINTR(err = tcsetattr(fd, when, &tt));
+
 	if (err < 0) {
 		if (complain)
 			printk("tcsetattr failed, errno = %d\n", errno);
diff -puN arch/um/kernel/process.c~EINTR_safety arch/um/kernel/process.c
--- uml-linux-2.6.7/arch/um/kernel/process.c~EINTR_safety	2004-06-23 18:43:16.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/kernel/process.c	2004-06-23 20:04:19.000000000 +0200
@@ -125,7 +125,7 @@ int start_fork_tramp(void *thread_arg, u
 	/* Start the process and wait for it to kill itself */
 	new_pid = clone(outer_tramp, (void *) sp, clone_flags, &arg);
 	if(new_pid < 0) return(-errno);
-	while(((err = waitpid(new_pid, &status, 0)) < 0) && (errno == EINTR)) ;
+	CATCH_EINTR(err = waitpid(new_pid, &status, 0));
 	if(err < 0) panic("Waiting for outer trampoline failed - errno = %d", 
 			  errno);
 	if(!WIFSIGNALED(status) || (WTERMSIG(status) != SIGKILL))
@@ -171,7 +171,7 @@ static int start_ptraced_child(void **st
 	pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL);
 	if(pid < 0)
 		panic("check_ptrace : clone failed, errno = %d", errno);
-	n = waitpid(pid, &status, WUNTRACED);
+	CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
 	if(n < 0)
 		panic("check_ptrace : wait failed, errno = %d", errno);
 	if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP))
@@ -188,7 +188,7 @@ static void stop_ptraced_child(int pid, 
 
 	if(ptrace(PTRACE_CONT, pid, 0, 0) < 0)
 		panic("check_ptrace : ptrace failed, errno = %d", errno);
-	n = waitpid(pid, &status, 0);
+	CATCH_EINTR(n = waitpid(pid, &status, 0));
 	if(!WIFEXITED(status) || (WEXITSTATUS(status) != exitcode))
 		panic("check_ptrace : child exited with status 0x%x", status);
 
@@ -224,7 +224,7 @@ void __init check_ptrace(void)
 		if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)
 			panic("check_ptrace : ptrace failed, errno = %d", 
 			      errno);
-		n = waitpid(pid, &status, WUNTRACED);
+		CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
 		if(n < 0)
 			panic("check_ptrace : wait failed, errno = %d", errno);
 		if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
@@ -251,7 +251,8 @@ void __init check_ptrace(void)
 	if(ptrace(PTRACE_SYSEMU, pid, 0, 0) >= 0) {
 		struct user_regs_struct regs;
 
-		if (waitpid(pid, &status, WUNTRACED) < 0)
+		CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
+		if (n < 0)
 			panic("check_ptrace : wait failed, errno = %d", errno);
 		if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
 			panic("check_ptrace : expected SIGTRAP, "
diff -puN arch/um/kernel/frame.c~EINTR_safety arch/um/kernel/frame.c
--- uml-linux-2.6.7/arch/um/kernel/frame.c~EINTR_safety	2004-06-23 18:46:29.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/kernel/frame.c	2004-06-23 20:04:19.000000000 +0200
@@ -21,6 +21,7 @@
 #include "sysdep/sigcontext.h"
 #include "frame_user.h"
 #include "kern_util.h"
+#include "user_util.h"
 #include "ptrace_user.h"
 #include "os.h"
 
@@ -40,7 +41,7 @@ static int capture_stack(int (*child)(vo
 	/* Wait for it to stop itself and continue it with a SIGUSR1 to force 
 	 * it into the signal handler.
 	 */
-	n = waitpid(pid, &status, WUNTRACED);
+	CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
 	if(n < 0){
 		printf("capture_stack : waitpid failed - errno = %d\n", errno);
 		exit(1);
@@ -60,7 +61,7 @@ static int capture_stack(int (*child)(vo
 	 * At this point, the handler has stuffed the addresses of
 	 * sig, sc, and SA_RESTORER in raw.
 	 */
-	n = waitpid(pid, &status, WUNTRACED);
+	CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
 	if(n < 0){
 		printf("capture_stack : waitpid failed - errno = %d\n", errno);
 		exit(1);
@@ -82,7 +83,8 @@ static int capture_stack(int (*child)(vo
 		       errno);
 		exit(1);
 	}
-	if(waitpid(pid, &status, 0) < 0){
+	CATCH_EINTR(n = waitpid(pid, &status, 0));
+	if(n < 0){
 		printf("capture_stack : waitpid failed - errno = %d\n", errno);
 		exit(1);
 	}
diff -puN arch/um/drivers/net_user.c~EINTR_safety arch/um/drivers/net_user.c
--- uml-linux-2.6.7/arch/um/drivers/net_user.c~EINTR_safety	2004-06-23 19:35:31.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/drivers/net_user.c	2004-06-23 20:05:42.000000000 +0200
@@ -175,7 +175,8 @@ static int change_tramp(char **argv, cha
 
 	os_close_file(fds[1]);
 	read_output(fds[0], output, output_len);
-	waitpid(pid, NULL, 0);	
+
+	CATCH_EINTR(err = waitpid(pid, NULL, 0));
 	return(pid);
 }
 
diff -puN arch/um/drivers/slip_user.c~EINTR_safety arch/um/drivers/slip_user.c
--- uml-linux-2.6.7/arch/um/drivers/slip_user.c~EINTR_safety	2004-06-23 19:35:32.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/drivers/slip_user.c	2004-06-23 20:04:19.000000000 +0200
@@ -4,7 +4,7 @@
 #include <stddef.h>
 #include <sched.h>
 #include <string.h>
-#include <sys/errno.h>
+#include <errno.h>
 #include <sys/termios.h>
 #include <sys/wait.h>
 #include <sys/signal.h>
@@ -100,7 +100,9 @@ static int slip_tramp(char **argv, int f
 			printk("%s", output);
 			kfree(output);
 		}
-		if(waitpid(pid, &status, 0) < 0) err = errno;
+		CATCH_EINTR(err = waitpid(pid, &status, 0));
+		if(err < 0)
+			err = errno;
 		else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 0)){
 			printk("'%s' didn't exit with status 0\n", argv[0]);
 			err = -EINVAL;
diff -puN arch/um/drivers/slirp_user.c~EINTR_safety arch/um/drivers/slirp_user.c
--- uml-linux-2.6.7/arch/um/drivers/slirp_user.c~EINTR_safety	2004-06-23 19:35:33.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/drivers/slirp_user.c	2004-06-23 20:04:19.000000000 +0200
@@ -4,7 +4,7 @@
 #include <stddef.h>
 #include <sched.h>
 #include <string.h>
-#include <sys/errno.h>
+#include <errno.h>
 #include <sys/wait.h>
 #include <sys/signal.h>
 #include "user_util.h"
@@ -113,13 +113,13 @@ static void slirp_close(int fd, void *da
 	}
 #endif
 
-	err = waitpid(pri->pid, &status, WNOHANG);
-	if(err<0) {
+	CATCH_EINTR(err = waitpid(pri->pid, &status, WNOHANG));
+	if(err < 0) {
 		printk("slirp_close: waitpid returned %d\n", errno);
 		return;
 	}
 
-	if(err==0) {
+	if(err == 0) {
 		printk("slirp_close: process %d has not exited\n");
 		return;
 	}
diff -puN arch/um/kernel/helper.c~EINTR_safety arch/um/kernel/helper.c
--- uml-linux-2.6.7/arch/um/kernel/helper.c~EINTR_safety	2004-06-23 19:35:34.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/kernel/helper.c	2004-06-23 20:04:19.000000000 +0200
@@ -12,6 +12,7 @@
 #include <sys/wait.h>
 #include "user.h"
 #include "kern_util.h"
+#include "user_util.h"
 #include "os.h"
 
 struct helper_data {
@@ -96,7 +97,7 @@ int run_helper(void (*pre_exec)(void *),
 		goto out_kill;
 	}
 	else if(n != 0){
-		waitpid(pid, NULL, 0);
+		CATCH_EINTR(n = waitpid(pid, NULL, 0));
 		pid = -errno;
 	}
 
diff -puN arch/um/kernel/skas/exec_user.c~EINTR_safety arch/um/kernel/skas/exec_user.c
--- uml-linux-2.6.7/arch/um/kernel/skas/exec_user.c~EINTR_safety	2004-06-23 19:35:36.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/kernel/skas/exec_user.c	2004-06-23 20:04:19.000000000 +0200
@@ -11,6 +11,7 @@
 #include <sys/ptrace.h>
 #include "user.h"
 #include "kern_util.h"
+#include "user_util.h"
 #include "os.h"
 #include "time_user.h"
 
@@ -26,7 +27,7 @@ static int user_thread_tramp(void *arg)
 
 int user_thread(unsigned long stack, int flags)
 {
-	int pid, status;
+	int pid, status, err;
 
 	pid = clone(user_thread_tramp, (void *) stack_sp(stack), 
 		    flags | CLONE_FILES | SIGCHLD, NULL);
@@ -35,7 +36,8 @@ int user_thread(unsigned long stack, int
 		return(pid);
 	}
 
-	if(waitpid(pid, &status, WUNTRACED) < 0){
+	CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
+	if(err < 0){
 		printk("user_thread - waitpid failed, errno = %d\n", errno);
 		return(-errno);
 	}
diff -puN arch/um/kernel/trap_user.c~EINTR_safety arch/um/kernel/trap_user.c
--- uml-linux-2.6.7/arch/um/kernel/trap_user.c~EINTR_safety	2004-06-23 19:35:37.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/kernel/trap_user.c	2004-06-23 20:04:19.000000000 +0200
@@ -32,7 +32,14 @@ void kill_child_dead(int pid)
 {
 	kill(pid, SIGKILL);
 	kill(pid, SIGCONT);
-	while(waitpid(pid, NULL, 0) > 0) kill(pid, SIGCONT);
+	do {
+		int n;
+		CATCH_EINTR(n = waitpid(pid, NULL, 0));
+		if (n > 0)
+			kill(pid, SIGCONT);
+		else
+			break;
+	} while(1);
 }
 
 /* Unlocked - don't care if this is a bit off */
diff -puN arch/um/kernel/tt/exec_user.c~EINTR_safety arch/um/kernel/tt/exec_user.c
--- uml-linux-2.6.7/arch/um/kernel/tt/exec_user.c~EINTR_safety	2004-06-23 19:35:38.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/kernel/tt/exec_user.c	2004-06-23 20:04:19.000000000 +0200
@@ -19,13 +19,18 @@
 void do_exec(int old_pid, int new_pid)
 {
 	unsigned long regs[FRAME_SIZE];
+	int err;
 
 	if((ptrace(PTRACE_ATTACH, new_pid, 0, 0) < 0) ||
-	   (ptrace(PTRACE_CONT, new_pid, 0, 0) < 0) ||
-	   (waitpid(new_pid, 0, WUNTRACED) < 0))
+	   (ptrace(PTRACE_CONT, new_pid, 0, 0) < 0))
 		tracer_panic("do_exec failed to attach proc - errno = %d",
 			     errno);
 
+	CATCH_EINTR(err = waitpid(new_pid, 0, WUNTRACED));
+	if (err < 0)
+		tracer_panic("do_exec failed to attach proc in waitpid - errno = %d",
+			     errno);
+
 	if(ptrace_getregs(old_pid, regs) < 0)
 		tracer_panic("do_exec failed to get registers - errno = %d",
 			     errno);
diff -puN arch/um/kernel/tt/ptproxy/proxy.c~EINTR_safety arch/um/kernel/tt/ptproxy/proxy.c
--- uml-linux-2.6.7/arch/um/kernel/tt/ptproxy/proxy.c~EINTR_safety	2004-06-23 19:35:40.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/kernel/tt/ptproxy/proxy.c	2004-06-23 20:04:19.000000000 +0200
@@ -272,7 +272,7 @@ void fake_child_exit(void)
 
 	child_proxy(1, W_EXITCODE(0, 0));
 	while(debugger.waiting == 1){
-		pid = waitpid(debugger.pid, &status, WUNTRACED);
+		CATCH_EINTR(pid = waitpid(debugger.pid, &status, WUNTRACED));
 		if(pid != debugger.pid){
 			printk("fake_child_exit - waitpid failed, "
 			       "errno = %d\n", errno);
@@ -280,7 +280,7 @@ void fake_child_exit(void)
 		}
 		debugger_proxy(status, debugger.pid);
 	}
-	pid = waitpid(debugger.pid, &status, WUNTRACED);
+	CATCH_EINTR(pid = waitpid(debugger.pid, &status, WUNTRACED));
 	if(pid != debugger.pid){
 		printk("fake_child_exit - waitpid failed, "
 		       "errno = %d\n", errno);
diff -puN arch/um/kernel/tt/tracer.c~EINTR_safety arch/um/kernel/tt/tracer.c
--- uml-linux-2.6.7/arch/um/kernel/tt/tracer.c~EINTR_safety	2004-06-23 19:35:41.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/kernel/tt/tracer.c	2004-06-23 20:04:19.000000000 +0200
@@ -192,7 +192,7 @@ int tracer(int (*init_proc)(void *), voi
 	printf("tracing thread pid = %d\n", tracing_pid);
 
 	pid = clone(signal_tramp, sp, CLONE_FILES | SIGCHLD, init_proc);
-	n = waitpid(pid, &status, WUNTRACED);
+	CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
 	if(n < 0){
 		printf("waitpid on idle thread failed, errno = %d\n", errno);
 		exit(1);
@@ -233,7 +233,7 @@ int tracer(int (*init_proc)(void *), voi
 	}
 	set_cmdline("(tracing thread)");
 	while(1){
-		pid = waitpid(-1, &status, WUNTRACED);
+		CATCH_EINTR(pid = waitpid(-1, &status, WUNTRACED));
 		if(pid <= 0){
 			if(errno != ECHILD){
 				printf("wait failed - errno = %d\n", errno);
diff -puN arch/um/os-Linux/drivers/ethertap_user.c~EINTR_safety arch/um/os-Linux/drivers/ethertap_user.c
--- uml-linux-2.6.7/arch/um/os-Linux/drivers/ethertap_user.c~EINTR_safety	2004-06-23 19:35:43.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/os-Linux/drivers/ethertap_user.c	2004-06-23 20:04:19.000000000 +0200
@@ -16,6 +16,7 @@
 #include <net/if.h>
 #include "user.h"
 #include "kern_util.h"
+#include "user_util.h"
 #include "net_user.h"
 #include "etap.h"
 #include "helper.h"
@@ -125,7 +126,8 @@ static int etap_tramp(char *dev, char *g
 	if(c != 1){
 		printk("etap_tramp : uml_net failed\n");
 		err = -EINVAL;
-		if(waitpid(pid, &status, 0) < 0)
+		CATCH_EINTR(n = waitpid(pid, &status, 0));
+		if(n < 0)
 			err = -errno;
 		else if(!WIFEXITED(status) || (WEXITSTATUS(status) != 1))
 			printk("uml_net didn't exit with status 1\n");
diff -puN arch/um/os-Linux/drivers/tuntap_user.c~EINTR_safety arch/um/os-Linux/drivers/tuntap_user.c
--- uml-linux-2.6.7/arch/um/os-Linux/drivers/tuntap_user.c~EINTR_safety	2004-06-23 19:35:45.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/os-Linux/drivers/tuntap_user.c	2004-06-23 20:04:19.000000000 +0200
@@ -18,6 +18,7 @@
 #include "net_user.h"
 #include "tuntap.h"
 #include "kern_util.h"
+#include "user_util.h"
 #include "user.h"
 #include "helper.h"
 #include "os.h"
@@ -108,7 +109,7 @@ static int tuntap_open_tramp(char *gate,
 		       errno);
 		return(-errno);
 	}
-	waitpid(pid, NULL, 0);
+	CATCH_EINTR(waitpid(pid, NULL, 0));
 
 	cmsg = CMSG_FIRSTHDR(&msg);
 	if(cmsg == NULL){
diff -puN arch/um/os-Linux/process.c~EINTR_safety arch/um/os-Linux/process.c
--- uml-linux-2.6.7/arch/um/os-Linux/process.c~EINTR_safety	2004-06-23 19:35:46.000000000 +0200
+++ uml-linux-2.6.7-paolo/arch/um/os-Linux/process.c	2004-06-23 20:04:19.000000000 +0200
@@ -12,6 +12,7 @@
 #include <sys/wait.h>
 #include "os.h"
 #include "user.h"
+#include "user_util.h"
 
 #define ARBITRARY_ADDR -1
 #define FAILURE_PID    -1
@@ -87,7 +88,7 @@ void os_kill_process(int pid, int reap_c
 {
 	kill(pid, SIGKILL);
 	if(reap_child)
-		waitpid(pid, NULL, 0);
+		CATCH_EINTR(waitpid(pid, NULL, 0));
 		
 }
 

_

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-06-24 20:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-19  0:19 [uml-devel] Kernel panic: handle_trap - failed to wait at end of syscall, errno = 4, status = 1151 Christopher S. Aker
2004-06-19 17:39 ` Jeff Dike
2004-06-22 13:18   ` Joe Marzot
2004-06-22 15:43     ` Jeff Dike
2004-06-23 18:09       ` [PATCH] The fix for: Re: [uml-devel] Kernel panic: handle_trap - failed to wait at end of syscall, BlaisorBlade

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