New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Focal armhf and arm64 builds fail with semop: function not implemented: #36
Comments
Edit: Oops, disregard, that's waaaay too old. |
This one was the first I see failing: https://build.osrfoundation.org/view/All/job/ign-math6-debbuilder/396/console
|
To reproduce locally:
Also, running |
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
int main() {
struct sembuf sops[1];
int semid = semget(12345, 1, IPC_CREAT|0600);
sops[0].sem_num = 0;
sops[0].sem_op = -1;
sops[0].sem_flg = SEM_UNDO;
if (semop(semid, sops, 1) == -1) {
perror("semop");
return 1;
}
return 0;
} Expected behavior: it should block forever because "If sem_op is less than zero [...] semncnt (the counter of threads waiting for this semaphore's value to increase) is incremented by one and the thread sleeps" Actual behavior:
|
Running
It looks like the syscall returning
Since
|
Minimal example calling #define _GNU_SOURCE // Compiler warns semtimedop is implicitly declared without this
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
int main() {
struct sembuf sops[1];
int semid = semget(12345, 1, IPC_CREAT|0600);
sops[0].sem_num = 0;
sops[0].sem_op = -1;
sops[0].sem_flg = SEM_UNDO;
if (semtimedop(semid, sops, 1, NULL) == -1) {
perror("semtimedop");
return 1;
}
return 0;
} root@c9b5a3fddeba:/tmp# gcc semop.c
root@c9b5a3fddeba:/tmp# ./a.out
semtimedop: Function not implemented |
Adding a sleep to the above program and running
sleep first code#define _GNU_SOURCE // Compiler warns semtimedop is implicitly declared without this
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <unistd.h>
int main() {
sleep(15);
struct sembuf sops[1];
int semid = semget(12345, 1, IPC_CREAT|0600);
sops[0].sem_num = 0;
sops[0].sem_op = -1;
sops[0].sem_flg = SEM_UNDO;
if (semtimedop(semid, sops, 1, NULL) == -1) {
perror("semtimedop");
return 1;
}
return 0;
} |
I cam reproduce the issue outside of a docker container by building
Output:
If I build qemu
Then in the
|
Getting the example out of the docker container allowed me to run gdb with It looks like the root cause is
I think what happened is we were using |
Nice analysis, @sloretz . The "correct" way to fix this does seem to be to implement However, we may be able to do a short-term workaround as well. If we do an LD_PRELOAD inside of the qemu userland, and redirect the implementation of |
It looks like that works! Now to add it to the Dockerfile #define _GNU_SOURCE
#include <unistd.h>
#include <asm/unistd.h>
#include <sys/syscall.h>
/* glibc 2.31 wraps semop() as a call to semtimedop() with the timespec set to NULL
* qemu 3.1 doesn't support semtimedop(), so this wrapper syscalls the real semop()
*/
int semop(int semid, struct sembuf *sops, unsigned nsops)
{
return syscall(__NR_semop, semid, sops, nsops);
}
|
I'm happy to have found this discussion. I'm using qemu to autobuild packages for Arch Linux ARM. I use qemu 4.2 for my builds which still seems to have this problem: https://travis-ci.com/github/VDR4Arch/vdr4arch/jobs/326884620#L1596 I've filed an upstream bug just to see how the current status is about fixing this directly in qemu: https://bugs.launchpad.net/qemu/+bug/1876568 Edit: Your workaround does fix my issue, so I think it is proven that qemu 4.2 still has the issue. This is the fix I use for my build tool: |
Opening a ticket with notes copied from: #35 . See also @clalancette's comment #35 (comment) . @j-rivero also says similar errors are happening on http://build.osrfoundation.org
The Noetic Focal armhf and arm64 jobs jobs all started failling 2 days ago.
Random Notes
semop()
to decrement a semaphoreFunction not implemented
is whatperror()
prints when a syscall returnsENOSYS
ENOSYS
is not one of the documented error codes forsemop()
semop()
, though I wasn't able to find a spot where it would returnENOSYS
in thestable-3.1
branch.osrf/ubuntu_armhf:focal
andosrf_ubuntu_arm64:focal
, meaning they have exactly the same version of qemu, so that hasn't changed.fakeroot
,1.24-1
fakeroot
-> containerglibc
->qemu
-> hostglibc
->kernel
glibc
version2.30-0ubuntu3
glibc
version2.31-0ubuntu6
The text was updated successfully, but these errors were encountered: