* at least two bugs in strace-3.1-5
@ 1998-09-21 14:41 Richard Black
1998-09-21 23:35 ` Thomas Bogendoerfer
0 siblings, 1 reply; 4+ messages in thread
From: Richard Black @ 1998-09-21 14:41 UTC (permalink / raw)
To: redhat-bugs, axp-list; +Cc: rjb
Summary:
I discovered a bug in strace (on alpha), and on investigating discovered that
the source RPM appears not to compile on either alpha or intel (multiple
problems)
Details:
1)
The following program, when run under strace on alpha linux shows that strace
on alpha linux does not record the mmap call correctly. It is recorded
correctly on intel linux.
#include <unistd.h>
#include <sys/mman.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
int fd = open("/etc/passwd", O_RDONLY);
if (mmap(NULL, 8192, PROT_READ, MAP_PRIVATE, fd, 0) == 0)
perror("mmap:");
return 0;
}
gives:
open("/etc/passwd", O_RDONLY) = 3
mmap(0, 0, 0x1ffff480, 0 /* MAP_??? */, 2, 0) = 0x1555556a000
exit(0) = ?
on alpha, but the correct
open("/etc/passwd", O_RDONLY) = 5
mmap(0, 8192, PROT_READ, MAP_PRIVATE, 5, 0) = 0x400b5000
_exit(0) = ?
on intel.
2)
- Also the strace source rpm (even with the supplied patches) does not compile
on either alpha or intel because of a missing kernel include file.
strace-3.1/process.c includes <sys/prctl.h> which in turn includes
<linux/prctl.h>, but that header file does not exist.
- On intel, the file syscall.c does not compile because of the errors:
syscall.c: In function `trace_syscall':
syscall.c:513: `ORIG_EAX' undeclared (first use this function)
syscall.c:513: (Each undeclared identifier is reported only once
syscall.c:513: for each function it appears in.)
syscall.c:613: `EAX' undeclared (first use this function)
make: *** [syscall.o] Error 1
- On alpha even if config.h is modified to say
#undef HAVE_PRCTL
the build still fails in
sock.c: In function `sock_ioctl':
sock.c:60: warning: implicit declaration of function `_IOW'
sock.c:60: parse error before `int'
sock.c:76: warning: unreachable code at beginning of switch statement
It is necessary to also include sys/ioctl.h to get the (buggy) binary shipped
in the binary rpm file.
Richard
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: at least two bugs in strace-3.1-5 1998-09-21 14:41 at least two bugs in strace-3.1-5 Richard Black @ 1998-09-21 23:35 ` Thomas Bogendoerfer 1998-09-23 17:48 ` Another bug in strace-3.1 Richard Black 0 siblings, 1 reply; 4+ messages in thread From: Thomas Bogendoerfer @ 1998-09-21 23:35 UTC (permalink / raw) To: axp-list On Mon, Sep 21, 1998 at 03:41:07PM +0100, Richard Black wrote: > The following program, when run under strace on alpha linux shows that strace > on alpha linux does not record the mmap call correctly. It is recorded > correctly on intel linux. below is my current patchset for strace. It fixes the mmap bug and some other oddities. > - Also the strace source rpm (even with the supplied patches) does not > compile strace-3.1-7 (RedHat 5.1) compiled at least on my Alpha. The patch is on top of it. Thomas. diff -ru strace-3.1-orig/defs.h strace-3.1/defs.h --- strace-3.1-orig/defs.h Tue Sep 22 01:22:02 1998 +++ strace-3.1/defs.h Sun Jun 29 15:06:34 1997 @@ -113,6 +113,7 @@ short flags; /* See below for TCB_ values */ int pid; /* Process Id of this entry */ long scno; /* System call number */ + long oscno; /* old System call for handling signals */ int u_nargs; /* System call arguments */ long u_arg[MAX_ARGS]; /* System call arguments */ int u_error; /* Error code */ diff -ru strace-3.1-orig/file.c strace-3.1/file.c --- strace-3.1-orig/file.c Tue Sep 22 01:22:03 1998 +++ strace-3.1/file.c Sun Jun 29 14:38:46 1997 @@ -297,7 +297,7 @@ static void printstat(tcp, addr) struct tcb *tcp; -int addr; +long addr; { struct stat statbuf; @@ -306,7 +306,7 @@ return; } if (syserror(tcp) || !verbose(tcp)) { - tprintf("%#x", addr); + tprintf("%#lx", addr); return; } if (umove(tcp, addr, &statbuf) < 0) { diff -ru strace-3.1-orig/linux/alpha/syscallent.h strace-3.1/linux/alpha/syscallent.h --- strace-3.1-orig/linux/alpha/syscallent.h Fri May 17 04:38:46 1996 +++ strace-3.1/linux/alpha/syscallent.h Tue Sep 22 01:06:09 1998 @@ -99,7 +99,7 @@ { 2, TF, sys_lstat, "lstat" }, /* 68 */ { 5, 0, printargs, "SYS_69" }, /* 69 */ { 5, 0, printargs, "SYS_70" }, /* 70 */ - { 1, 0, sys_mmap, "mmap" }, /* 71 */ + { 6, 0, sys_mmap, "mmap" }, /* 71 */ { 5, 0, printargs, "SYS_72" }, /* 72 */ { 2, 0, sys_munmap, "munmap" }, /* 73 */ { 3, 0, sys_mprotect, "mprotect" }, /* 74 */ diff -ru strace-3.1-orig/process.c strace-3.1/process.c --- strace-3.1-orig/process.c Tue Sep 22 01:22:03 1998 +++ strace-3.1/process.c Sun May 19 08:40:36 1996 @@ -1143,6 +1143,11 @@ tprintf("release=\"%s\", version=\"%s\", ", uname.release, uname.version); tprintf("machine=\"%s\"", uname.machine); +#ifdef LINUX +#ifndef ALPHA + tprintf(", domainname=\"%s\"", uname.domainname); +#endif /* ALPHA */ +#endif /* LINUX */ tprintf("}"); } else diff -ru strace-3.1-orig/strace.c strace-3.1/strace.c --- strace-3.1-orig/strace.c Sun May 19 08:40:37 1996 +++ strace-3.1/strace.c Sun Jun 29 15:08:17 1997 @@ -1311,6 +1311,7 @@ break; case PR_SIGNALLED: if (!cflag && (qual_flags[what] & QUAL_SIGNAL)) { + tcp->oscno = tcp->scno; printleader(tcp); tprintf("--- %s (%s) ---", signalent[what], strsignal(what)); diff -ru strace-3.1-orig/syscall.c strace-3.1/syscall.c --- strace-3.1-orig/syscall.c Tue Sep 22 01:22:03 1998 +++ strace-3.1/syscall.c Tue Sep 22 01:05:07 1998 @@ -720,6 +720,7 @@ } if (tcp->flags & TCB_REPRINT) { + tcp->scno = tcp->oscno; printleader(tcp); tprintf("<... "); if (tcp->scno >= nsyscalls) @@ -848,7 +849,10 @@ #ifdef ALPHA { int i; - tcp->u_nargs = sysent[tcp->scno].nargs; + if (scno < 400) + tcp->u_nargs = sysent[tcp->scno].nargs; + else + tcp->u_nargs = 5; for (i = 0; i < tcp->u_nargs; i++) { if (upeek(pid, REG_A0+i, &tcp->u_arg[i]) < 0) return -1; -- See, you not only have to be a good coder to create a system like Linux, you have to be a sneaky bastard too ;-) [Linus Torvalds in <4rikft$7g5@linux.cs.Helsinki.FI>] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Another bug in strace-3.1 1998-09-21 23:35 ` Thomas Bogendoerfer @ 1998-09-23 17:48 ` Richard Black 1998-09-24 19:10 ` Thomas Bogendoerfer 0 siblings, 1 reply; 4+ messages in thread From: Richard Black @ 1998-09-23 17:48 UTC (permalink / raw) To: axp-list, Thomas Bogendoerfer, bugs; +Cc: rjb > On Mon, Sep 21, 1998 at 03:41:07PM +0100, Richard Black wrote: > > The following program, when run under strace on alpha linux shows that > > strace on alpha linux does not record the mmap call correctly. It is > > recorded correctly on intel linux. > > below is my current patchset for strace. It fixes the mmap bug and > some other oddities. > > - Also the strace source rpm (even with the supplied patches) does not > > compile > strace-3.1-7 (RedHat 5.1) compiled at least on my Alpha. The patch is > on top of it. Many thanks to Thomas for his patches, though I have looked on ftp.redhat.com and can only find strace-3.1-5. Here is another problem -- the fstat (and related) calls appear to report something wrong i.e. neither the contents of the stat buffer before the call, nor the contents after the call. This happens on *both* intel and alpha. Here is the program: #include <unistd.h> #include <sys/mman.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <string.h> int main(int argc, char **argv) { int fd = open("/etc/passwd", O_RDONLY); struct stat s; char buf[1024]; /* just to de-cloud strace log */ s.st_mode = 42; s.st_size = 12345678; if (fstat(fd, &s) < 0) perror("stat:"); sprintf(buf, "st_mode=%d, st_size=%ld\n", s.st_mode, s.st_size); write(1, buf, strlen(buf)); return 0; } and here is the output on intel: open("/etc/passwd", O_RDONLY) = 5 fstat(5, {st_mode=0, st_size=0, ...}) = 0 write(1, "st_mode=33188, st_size=585\n", 27st_mode=33188, st_size=585 ) = 27 _exit(0) = ? and here is the output on alpha: open("/etc/passwd", O_RDONLY) = 3 fstat(3, {st_mode=01, st_size=906571131, ...}) = 0 write(1, "st_mode=33188, st_size=585\n", 27st_mode=33188, st_size=585 ) = 27 exit(0) = ? You can see that the information reported in the braces is completely wrong. Richard. PS: Curiosity -- why do the alpha systems start at fd 5 and the intel ones at fd 3? ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Another bug in strace-3.1 1998-09-23 17:48 ` Another bug in strace-3.1 Richard Black @ 1998-09-24 19:10 ` Thomas Bogendoerfer 0 siblings, 0 replies; 4+ messages in thread From: Thomas Bogendoerfer @ 1998-09-24 19:10 UTC (permalink / raw) To: Richard Black; +Cc: axp-list, bugs On Wed, Sep 23, 1998 at 06:48:19PM +0100, Richard Black wrote: > Many thanks to Thomas for his patches, though I have looked on ftp.redhat.com > and can only find strace-3.1-5. this sucks. strace-3.1-7 is on my PowerTools CD, but I couldn't find it on ftp.redhat.com either. There are more newer SRPMS on the PowerTools CD, which are _not_ on ftp.redhat.com:-( > Here is another problem -- the fstat (and related) calls appear to report > something wrong i.e. neither the contents of the stat buffer before the call, > nor the contents after the call. This happens on *both* intel and alpha. that's a mismatch between kernel structures and glibc structures. Below is a fix this problem. I've uploaded a SRPM, a Intel RPM and an Alpha RPM of the fixed strace. You can find them in ftp://ftp.franken.de/pub/people/tsbogend/strace/strace-3.1-9.*.rpm Thomas. diff -ru strace-3.1-orig/file.c strace-3.1/file.c --- strace-3.1-orig/file.c Thu Sep 24 12:15:39 1998 +++ strace-3.1/file.c Thu Sep 24 20:54:43 1998 @@ -413,8 +413,9 @@ } #endif -#ifdef LINUXSPARC +#ifdef LINUX /* Ugly, bug GLIBC makes this necessary. */ +#ifdef LINUXSPARC struct kernel_stat { unsigned short int st_dev; @@ -437,13 +438,59 @@ unsigned long int __unused5; }; #endif +#ifdef ALPHA +struct kernel_stat +{ + unsigned int st_dev; + unsigned int st_ino; + unsigned int st_mode; + unsigned int st_nlink; + unsigned int st_uid; + unsigned int st_gid; + unsigned int st_rdev; + long st_size; + unsigned long st_atime; + unsigned long st_mtime; + unsigned long st_ctime; + unsigned int st_blksize; + int st_blocks; + unsigned int st_flags; + unsigned int st_gen; +}; +#endif +#ifdef I386 +struct kernel_stat +{ + unsigned short st_dev; + unsigned short __pad1; + unsigned long st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned short st_rdev; + unsigned short __pad2; + unsigned long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + unsigned long st_atime; + unsigned long __unused1; + unsigned long st_mtime; + unsigned long __unused2; + unsigned long st_ctime; + unsigned long __unused3; + unsigned long __unused4; + unsigned long __unused5; +}; +#endif +#endif static void printstat(tcp, addr) struct tcb *tcp; -int addr; +long addr; { -#ifdef LINUXSPARC +#ifdef LINUX struct kernel_stat statbuf; #else struct stat statbuf; @@ -460,7 +506,7 @@ return; } if (syserror(tcp) || !verbose(tcp)) { - tprintf("%#x", addr); + tprintf("%#lx", addr); return; } if (umove(tcp, addr, &statbuf) < 0) { diff -ru strace-3.1-orig/linux/alpha/syscallent.h strace-3.1/linux/alpha/syscallent.h --- strace-3.1-orig/linux/alpha/syscallent.h Thu Sep 24 12:15:39 1998 +++ strace-3.1/linux/alpha/syscallent.h Thu Sep 24 12:21:35 1998 @@ -119,8 +119,8 @@ { 2, 0, sys_sethostname, "sethostname" }, /* 88 */ { 0, 0, sys_getdtablesize, "getdtablesize" }, /* 89 */ { 2, 0, sys_dup2, "dup2" }, /* 90 */ - { 2, 0, sys_fstat, "fstat" }, /* 91 */ - { 3, 0, sys_fcntl, "fcntl" }, /* 92 */ + { 2, TF, sys_fstat, "fstat" }, /* 91 */ + { 3, TF, sys_fcntl, "fcntl" }, /* 92 */ { 5, 0, sys_select, "select" }, /* 93 */ { 5, 0, printargs, "SYS_94" }, /* 94 */ { 1, 0, sys_fsync, "fsync" }, /* 95 */ -- See, you not only have to be a good coder to create a system like Linux, you have to be a sneaky bastard too ;-) [Linus Torvalds in <4rikft$7g5@linux.cs.Helsinki.FI>] ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1998-09-24 19:22 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 1998-09-21 14:41 at least two bugs in strace-3.1-5 Richard Black 1998-09-21 23:35 ` Thomas Bogendoerfer 1998-09-23 17:48 ` Another bug in strace-3.1 Richard Black 1998-09-24 19:10 ` Thomas Bogendoerfer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox