qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas K. Hüttel" <1906193@bugs.launchpad.net>
To: qemu-devel@nongnu.org
Subject: [Bug 1906193] Re: riscv32 user mode emulation: fork return values broken
Date: Tue, 15 Dec 2020 22:06:31 -0000	[thread overview]
Message-ID: <160806999180.15679.10246032395769282734.malone@chaenomeles.canonical.com> (raw)
In-Reply-To: 160669515259.21126.12178770886175022752.malonedeb@gac.canonical.com

I can confirm that the same binary works fine with qemu system
emulation:

(riscv-ilp32 qemu) (none) /tmp # ./wait-test-short 
(riscv-ilp32 qemu) (none) /tmp #

-- 
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


  parent reply	other threads:[~2020-12-15 22:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30  0:12 [Bug 1906193] [NEW] riscv32 user mode emulation: fork return values broken Dilfridge
2020-12-05  1:27 ` [Bug 1906193] " Andreas K. Hüttel
2020-12-15 22:06 ` Andreas K. Hüttel [this message]
2020-12-16 20:56 ` Andreas K. Hüttel
2020-12-16 21:05 ` Andreas K. Hüttel
2020-12-19 18:16 ` Alistair Francis
2020-12-19 23:21 ` Andreas K. Hüttel
2020-12-21 13:28 ` Andreas K. Hüttel
2020-12-21 21:44   ` Alistair Francis
2020-12-21 23:11 ` Richard Henderson
2020-12-26 17:53 ` Andreas K. Hüttel
2021-01-15 23:10 ` Alistair Francis
2021-01-16 18:58 ` Andreas K. Hüttel
2021-02-16 20:58 ` Alistair Francis
2021-04-30  8:57 ` Thomas Huth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=160806999180.15679.10246032395769282734.malone@chaenomeles.canonical.com \
    --to=1906193@bugs.launchpad.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).