Date: Tue, 01 Oct 2019 23:44:31 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 240989] Linuxulator: futexes can't be shared between 32- and 64-bit applications Message-ID: <bug-240989-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240989 Bug ID: 240989 Summary: Linuxulator: futexes can't be shared between 32- and 64-bit applications Product: Base System Version: 12.0-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: iwtcex@gmail.com Here's a small example: #define _GNU_SOURCE #include <assert.h> #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <unistd.h> #include <sys/syscall.h> #include <sys/time.h> #include <sys/types.h> #include <sys/mman.h> #include <linux/futex.h> #define SHM_FILE_PATH "/futex-bug" int main() { int fd = shm_open(SHM_FILE_PATH, O_CREAT | O_RDWR, 0777); assert(fd != -1); ftruncate(fd, 4); int* addr = mmap(NULL, 4, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); assert(addr != MAP_FAILED); close(fd); #ifdef WAIT struct timespec timeout = {.tv_sec = 1, .tv_nsec = 0}; int err = -1; do { err = syscall(SYS_futex, addr, FUTEX_WAIT, 0, &timeout, NULL, 0); if (err == -1) { printf("FUTEX_WAIT: %d [%s]\n", err, strerror(errno)); } else { printf("FUTEX_WAIT: %d\n", err); } } while (err == -1 && errno == ETIMEDOUT); shm_unlink(SHM_FILE_PATH); #else int err = syscall(SYS_futex, addr, FUTEX_WAKE, 1, NULL, NULL, 0); printf("FUTEX_WAKE: %d\n", err); #endif return 0; } Compile this with: /compat/linux/bin/cc -DWAIT -m32 --sysroot=/compat/linux futex_bug.c -lrt -o wait32 /compat/linux/bin/cc -m32 --sysroot=/compat/linux futex_bug.c -lrt -o wake32 /compat/linux/bin/cc -m64 --sysroot=/compat/linux futex_bug.c -lrt -o wake64 Run wait32, then try wake64 and wake32. -- You are receiving this mail because: You are the assignee for the bug.help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-240989-227>
