Skip to contentSkip to conversation

Syscall tracing bug

Linux-ia64 Andreas Schwab 2 participants 3 messages Sep 26, 2002

lore
Share & tools
lore
#0 lore raw

There is some problem with tracing syscall(2) in strace. It sees the actual syscall, but the arguments are shifted, with the first arg being the syscall number. For example:

$ cat syscall.c
#include <unistd.h>
#include <sys/syscall.h>

int
main ()
{
write (1, "Hello World\n", 12);
syscall (SYS_write, 1, "Hello World\n", 12);
return 0;
}

$ stace ./syscall
execve("./syscall", ["./syscall"], [/* 91 vars */]) = 0
uname({sys="Linux", node="sykes", ...}) = 0
brk(0)                                  = 0x6000000000000b30
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 5
fstat(5, {st_mode=S_IFREG|0644, st_size„982, ...}) = 0
mmap(NULL, 84982, PROT_READ, MAP_PRIVATE, 5, 0) = 0x2000000000040000
close(5)                                = 0
open("/lib/libc.so.6.1", O_RDONLY)      = 5
read(5, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0002\0\1\0\0\0\240@\3"..., 1024) = 1024
fstat(5, {st_mode=S_IFREG|0755, st_size#50193, ...}) = 0
mmap(NULL, 2260816, PROT_READ|PROT_EXEC, MAP_PRIVATE, 5, 0) = 0x2000000000058000
mprotect(0x2000000000260000, 130896, PROT_NONE) = 0
mmap(0x2000000000268000, 81920, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 5, 0x200000) = 0x2000000000268000
mmap(0x200000000027c000, 16208, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x200000000027c000
close(5)                                = 0
mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2000000000028000
munmap(0x2000000000040000, 84982)       = 0
write(1, "Hello World\n", 12Hello World
)           = 12
write(1027, ptrace: umoven: Input/output error
0x1, 4611686018427389952Hello World
)   = 12
exit(0)                                 = ?

Is this a bug in strace or in the kernel (maybe <asm/rse.h>)?

Andreas.

Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Andreas Schwab

Andreas> Is this a bug in strace or in the kernel (maybe Andreas> <asm/rse.h>)?

It's a bug in the strace you're using. This was fixed a long time ago in the CVS tree of strace. I haven't updated my tree since Oct 2001, but it has the right code: around line 1279 in syscall.c, it should say something like this:

			sof = (cfm >> 0) & 0x7f;
			sol = (cfm >> 7) & 0x7f;
			out0 = ia64_rse_skip_regs(rbs_end, -sof + sol);

	--david
#2 lore raw
In reply to Andreas Schwab

David Mosberger <[email protected]> writes:

|> >>>>> On Thu, 26 Sep 2002 21:19:31 +0200, Andreas Schwab <[email protected]> said:
|> 
|>   Andreas> Is this a bug in strace or in the kernel (maybe
|>   Andreas> <asm/rse.h>)?
|> 
|> It's a bug in the strace you're using.  This was fixed a long time ago
|> in the CVS tree of strace.  I haven't updated my tree since Oct 2001,
|> but it has the right code: around line 1279 in syscall.c, it should
|> say something like this:
|> 
|> 			sof = (cfm >> 0) & 0x7f;
|> 			sol = (cfm >> 7) & 0x7f;
|> 			out0 = ia64_rse_skip_regs(rbs_end, -sof + sol);

Thanks, it works now.

Andreas.

Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."