Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Wed, 8 Aug 2012 14:46:20 +0200
From: Yoran Heling <info@...hel.nl>
To: musl@...ts.openwall.com
Subject: Bug with fcntl() on mipsel

Hi,

I've been playing around a bit with the mips support in the new 0.9.3
release, but stumbled upon something that looks like a bug. This is on
debian-mipsel 6.0.5 running within qemu. The problem is with the
fcntl64() call, visible in the strace output below. It looks like
anything after the first argument is garbage.

Yoran.


$ cat test.c
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>

int main() {
  int fd = open("some_random_file", O_RDWR|O_CREAT, 0600);
  assert(fd > 0);
  struct flock lck;
  lck.l_type = F_WRLCK;
  lck.l_whence = SEEK_SET;
  lck.l_start = 0;
  lck.l_len = 0;
  int r = fcntl(fd, F_SETLK, &lck);
  printf("fcntl() = %d, errno = %d, strerror = %s\n", r, errno,
strerror(errno));
}

$ musl-gcc -static -D_FILE_OFFSET_BITS=64 test.c -o test-musl

$ gcc -D_FILE_OFFSET_BITS=64 test.c -o test-native

$ strace ./test-musl
execve("./test-musl", ["./test-musl"], [/* 14 vars */]) = 0
open("some_random_file", O_RDWR|O_CREAT|O_LARGEFILE, 0600) = 3
fcntl64(3, 0xd /* F_??? */, 0x7f901390) = -1 EINVAL (Invalid argument)
ioctl(1, TIOCNXCL, 0x7f900ea0)          = -1 ENOTTY (Inappropriate
ioctl for device)
writev(1, [{"fcntl() = -1, errno = 22, strerr"..., 53}, {"\n", 1}],
2fcntl() = -1, errno = 22, strerror = Invalid argument
) = 54
exit_group(54)                          = ?

stdout: fcntl() = -1, errno = 22, strerror = Invalid argument

$ strace ./test-native
execve("./test-native", ["./test-native"], [/* 14 vars */]) = 0
[...snip some ld.so loading and memory stuff..]
open("some_random_file", O_RDWR|O_CREAT|O_LARGEFILE, 0600) = 3
fcntl64(3, F_SETLK64, {type=F_WRLCK, whence=SEEK_SET, start=0, len=0},
0x7fb74398) = 0
fstat64(1, {st_mode=S_IFREG|0644, st_size=1942, ...}) = 0
old_mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x2ac5e000
write(1, "fcntl() = 0, errno = 0, strerror"..., 43fcntl() = 0, errno =
0, strerror = Success
) = 43
exit_group(43)                          = ?

stdout: fcntl() = 0, errno = 0, strerror = Success

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.