qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: riscv32 wait() problem, qemu or glibc?


From: Alistair Francis
Subject: Re: riscv32 wait() problem, qemu or glibc?
Date: Wed, 16 Sep 2020 08:18:25 -0700

On Mon, Sep 14, 2020 at 1:14 AM Andreas K. Hüttel via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> Hi,
>
> first of all, sorry for crossposting, but I'm dealing with many moving and
> experimental parts here...
>
> Situation: riscv32 (ilp32) qemu-user [1] chroot, Linux [2], glibc [3], gcc [4]
>
> The following small program outputs "child exited with status 40", which is
> rather unexpected (it should be 42). Any idea what is going on?
>
> (This is a simplified version of code in a configure test. The test has other
> potential issues [5], but in any case it cant produce useful results on
> riscv32 right now.)
>
> TIA,
> Andreas
>
> ====================================
> #include <stdlib.h>
> #include <unistd.h>
> #include <stdio.h>
> #include <sys/wait.h>
>
> main(c, v)
>      int c;
>      char **v;
> {
>   pid_t pid, p;
>   int s, i, n;
>
>   s = 0;
>   pid = fork();
>   if (pid == 0)
>     exit (42);
>
>   /* wait for the process */
>   p = wait(&s);

The wait() function internally in glibc calls waitid()
(https://github.com/bminor/glibc/blob/master/posix/wait.c#L25)

The waitid() function then does a waitid syscall
(https://github.com/bminor/glibc/blob/master/sysdeps/unix/sysv/linux/waitid.c#L29)

QEMU has support for waitid()
(https://github.com/qemu/qemu/blob/master/linux-user/syscall.c#L8308)
so this should work.

I also don't see any obvious size mismatches.

My guess is that somewhere in QEMU the types don't match what RV32 is
using. It's probably worth printing out the size, alignment and value
of everything at every stage and see what breaks.

AFAIK RV32 linux-user mode is pretty much un-tested. So their might be
all sorts of issues with it unfortunately.

Alistair

>   if (p != pid)
>     exit (255);
>
>   if (WIFEXITED(s))
>   {
>      int r=WEXITSTATUS(s);
>      printf("child exited with status %i\n",r);
>   }
> }
> ====================================
>
>
> [1] qemu built from git master, Sep 12, 2020 16:30:37 EEST
> [2] host kernel is 5.8.8
> [3] glibc-2.32 with the rv32 patch series backported from master
> [4] (Gentoo 10.2.0-r1 p2)
> [5] https://lists.gnu.org/archive/html/bug-bash/2020-09/msg00033.html
>
> --
> Andreas K. Hüttel
> dilfridge@gentoo.org
> Gentoo Linux developer
> (council, qa, toolchain, base-system, perl, libreoffice)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]