strace bug patch 4.4.98

Th. Steudten steudten at gmx.ch
Sun Sep 21 04:52:02 UTC 2003


Hello

OVERVIEW:

strace gives "umovestr: I/O error" same on stderr like the output, if
you don´t use the -o option. First i thought the systemcall failed, but
then i saw, it comes from the strace itself.

In the functions umove(n) and umovestr the ptrace() calls
can fail for some reasons. 2 cases are catched if started is value 1.
This is not the case here. The addr value is zero, so the EIO
errno is returned from ptrace().

FIX:
1. Catch the error of ptrace() in umovestr and umove if addr is NULL.
2. Give more output for perror() to see it comes from the strace programm.
3. OPEN: The started value is 0 if the function is enterd, but the first
    catch of ptrace-error tests this value - why??

PATCH:
--- strace-4.4.98/util.c.orig	2003-09-21 12:35:24.000000000 +0200
+++ strace-4.4.98/util.c	2003-09-21 13:20:50.000000000 +0200
@@ -599,7 +599,9 @@
  				return 0;
  			}
  			/* But if not started, we had a bogus address. */
-			perror("ptrace: umoven");
+			char buf[128];
+			snprintf(buf,sizeof(buf),"umoven: ptrace(PTRACE_PEEKDATA,%d,%lx,0)",pid,addr);
+			perror(buf);
  			return -1;
  		}
  		started = 1;
@@ -615,7 +617,11 @@
  				return 0;
  			}
  			if (addr != 0)
-				perror("ptrace: umoven");
+                        {
+			    char buf[128];
+			    snprintf(buf,sizeof(buf),"umoven: ptrace(PTRACE_PEEKDATA,%d,%lx,0)",pid,addr);
+			    perror(buf);
+		        }
  			return -1;
  		}
  		started = 1;
@@ -640,7 +646,9 @@
  		errno = 0;
  		u.val = ptrace(PTRACE_PEEKDATA, pid, (char *) addr, 0);
  		if (errno) {
-			perror("umoven");
+			char buf[128];
+			snprintf(buf,sizeof(buf),"umoven1: ptrace(PTRACE_PEEKDATA,%d,%lx,0)",pid,addr);
+			perror(buf);
  			return -1;
  		}
  		memcpy(laddr, &u.x[n], m = MIN(sizeof(long) - n, len));
@@ -650,7 +658,9 @@
  		errno = 0;
  		u.val = ptrace(PTRACE_PEEKDATA, pid, (char *) addr, 0);
  		if (errno) {
-			perror("umoven");
+			char buf[128];
+			snprintf(buf,sizeof(buf),"umoven2: ptrace(PTRACE_PEEKDATA,%d,%lx,0)",pid,addr);
+			perror(buf);
  			return -1;
  		}
  		memcpy(laddr, u.x, m = MIN(sizeof(long), len));
@@ -749,7 +759,9 @@
  				/* Ran into 'end of memory' - stupid "printpath" */
  				return 0;
  			}
-			perror("umovestr");
+			char buf[128];
+			snprintf(buf,sizeof(buf),"umovestr1: ptrace(PTRACE_PEEKDATA,%d,%lx,0)",pid,addr);
+			perror(buf);
  			return -1;
  		}
  		started = 1;
@@ -767,7 +779,12 @@
  				/* Ran into 'end of memory' - stupid "printpath" */
  				return 0;
  			}
-			perror("umovestr");
+                        if (addr != 0)
+                        {
+			    char buf[128];
+			    snprintf(buf,sizeof(buf),"umovestr2: ptrace(PTRACE_PEEKDATA,%d,%lx,0)",pid,addr);
+			    perror(buf);
+		        }
  			return -1;
  		}
  		started = 1;

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: strace-4.4.98-perror.patch
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20030921/92500739/attachment.ksh>


More information about the Strace-devel mailing list