This looks rather like a kernel bug, since the strace from woody doesn't
work either. I came up with this minimal testcase:
#include <sys/mman.h>
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
int main()
{
int fd=open("/etc/ld.so.cache", O_RDONLY);
struct stat buf;
if (!fstat(fd, &buf)) {
printf("stat successfull\n");
}
void* ret=mmap(NULL, 8421, PROT_READ, MAP_PRIVATE, fd, 0);
if (ret == MAP_FAILED) {
printf("Error: %s\n",strerror(errno));
} else {
printf("success: %p, %d.\n", ret, fd);
}
return 0;
}
succeeds when run without strace and fails with (linked statically to not
trip on the mmapping of libc6 problem again):
[EMAIL PROTECTED]:~$ strace ./a.out
execve("./a.out", ["./a.out"], [/* 13 vars */]) = 0
uname({sys="Linux", node="rem", ...}) = 0
brk(0) = 0x10005bfc
brk(0x10026bfc) = 0x10026bfc
brk(0x10027000) = 0x10027000
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=8421, ...}) = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x2aaa8000
write(1, "stat successfull\n", 17stat successfull
) = 17
old_mmap(NULL, 8421, PROT_READ, MAP_PRIVATE, 3, 0) = -1 EBADF (Bad file
descriptor)
write(1, "Error: Bad file descriptor\n", 27Error: Bad file descriptor
) = 27
munmap(0x2aaa8000, 4096) = 0
SYS_4246( <unfinished ... exit status 0>
Ptrace vs. mmap problem?
Cheers,
-- Guido
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]