Here's qemu's own strace log: farino ~ # /usr/bin/qemu-riscv32 -strace /chroot/riscv-ilp32/tmp/wait-test-short 10123 brk(NULL) = 0x00073000 10123 brk(0x00073880) = 0x00073880 10123 uname(0x407ffed8) = 0 10123 readlinkat(AT_FDCWD,"/proc/self/exe",0x407feff0,4096) = 39 10123 brk(0x00094880) = 0x00094880 10123 brk(0x00095000) = 0x00095000 10123 mprotect(0x0006e000,8192,PROT_READ) = 0 10123 clone(CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|0x11,child_stack=0x00000000,parent_tidptr=0x00000000,tls=0x00000000,child_tidptr=0x00073068) = 10125 10123 clone(CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|0x11,child_stack=0x00000000,parent_tidptr=0x00000000,tls=0x00000000,child_tidptr=0x00073068) = 0 10125 exit_group(42) 10123 waitid(0,-1,0x407fff8c,0x4) = 0 10123 statx(1,"",AT_EMPTY_PATH,STATX_BASIC_STATS,0x407ff8e8) = 0 child wants to return 42 (0x2A), parent received 40 (0x28), difference -2 10123 write(1,0x73ad0,74) = 74 10123 exit_group(0)
-- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1906193 Title: riscv32 user mode emulation: fork return values broken Status in QEMU: New Bug description: When running in a chroot with riscv32 (on x86_64; qemu git master as of today): The following short program forks; the child immediately returns with exit(42). The parent checks for the return value - and obtains 40! gcc-10.2 =============================================== #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); if (p != pid) exit (255); if (WIFEXITED(s)) { int r=WEXITSTATUS(s); if (r!=42) { printf("child wants to return %i (0x%X), parent received %i (0x%X), difference %i\n",42,42,r,r,r-42); } } } =============================================== (riscv-ilp32 chroot) farino /tmp # ./wait-test-short child wants to return 42 (0x2A), parent received 40 (0x28), difference -2 =============================================== (riscv-ilp32 chroot) farino /tmp # gcc --version gcc (Gentoo 10.2.0-r1 p2) 10.2.0 Copyright (C) 2020 Free Software Foundation, Inc. Dies ist freie Software; die Kopierbedingungen stehen in den Quellen. Es gibt KEINE Garantie; auch nicht für MARKTGÄNGIGKEIT oder FÜR SPEZIELLE ZWECKE. (riscv-ilp32 chroot) farino /tmp # ld --version GNU ld (Gentoo 2.34 p6) 2.34.0 Copyright (C) 2020 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version. This program has absolutely no warranty. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1906193/+subscriptions