Not sure if this helps in any way, but I tried if the problem is specific to
the return value 42. Leading to more confusing results... though this looks
more like an emulator problem than a libc problem to me now.
Happy to debug further, but with limited ideas on how to proceed.
(riscv-ilp32 chroot) farino /tmp # ./wait-test
child wants to return 34 (0x22), parent received 32 (0x20), difference -2
child wants to return 35 (0x23), parent received 33 (0x21), difference -2
child wants to return 36 (0x24), parent received 34 (0x22), difference -2
child wants to return 37 (0x25), parent received 35 (0x23), difference -2
child wants to return 38 (0x26), parent received 36 (0x24), difference -2
child wants to return 39 (0x27), parent received 37 (0x25), difference -2
child wants to return 40 (0x28), parent received 38 (0x26), difference -2
child wants to return 41 (0x29), parent received 39 (0x27), difference -2
child wants to return 42 (0x2A), parent received 40 (0x28), difference -2
child wants to return 43 (0x2B), parent received 41 (0x29), difference -2
child wants to return 44 (0x2C), parent received 42 (0x2A), difference -2
child wants to return 45 (0x2D), parent received 43 (0x2B), difference -2
child wants to return 46 (0x2E), parent received 44 (0x2C), difference -2
child wants to return 47 (0x2F), parent received 45 (0x2D), difference -2
child wants to return 48 (0x30), parent received 46 (0x2E), difference -2
child wants to return 49 (0x31), parent received 47 (0x2F), difference -2
child wants to return 50 (0x32), parent received 48 (0x30), difference -2
child wants to return 51 (0x33), parent received 49 (0x31), difference -2
child wants to return 52 (0x34), parent received 50 (0x32), difference -2
child wants to return 53 (0x35), parent received 51 (0x33), difference -2
child wants to return 54 (0x36), parent received 52 (0x34), difference -2
child wants to return 55 (0x37), parent received 53 (0x35), difference -2
child wants to return 56 (0x38), parent received 54 (0x36), difference -2
child wants to return 57 (0x39), parent received 55 (0x37), difference -2
child wants to return 58 (0x3A), parent received 56 (0x38), difference -2
child wants to return 59 (0x3B), parent received 57 (0x39), difference -2
child wants to return 60 (0x3C), parent received 58 (0x3A), difference -2
child wants to return 61 (0x3D), parent received 59 (0x3B), difference -2
child wants to return 62 (0x3E), parent received 60 (0x3C), difference -2
child wants to return 63 (0x3F), parent received 61 (0x3D), difference -2
child wants to return 64 (0x40), parent received 62 (0x3E), difference -2
child wants to return 162 (0xA2), parent received 160 (0xA0), difference -2
child wants to return 163 (0xA3), parent received 161 (0xA1), difference -2
child wants to return 164 (0xA4), parent received 162 (0xA2), difference -2
child wants to return 165 (0xA5), parent received 163 (0xA3), difference -2
child wants to return 166 (0xA6), parent received 164 (0xA4), difference -2
child wants to return 167 (0xA7), parent received 165 (0xA5), difference -2
child wants to return 168 (0xA8), parent received 166 (0xA6), difference -2
child wants to return 169 (0xA9), parent received 167 (0xA7), difference -2
child wants to return 170 (0xAA), parent received 168 (0xA8), difference -2
child wants to return 171 (0xAB), parent received 169 (0xA9), difference -2
child wants to return 172 (0xAC), parent received 170 (0xAA), difference -2
child wants to return 173 (0xAD), parent received 171 (0xAB), difference -2
child wants to return 174 (0xAE), parent received 172 (0xAC), difference -2
child wants to return 175 (0xAF), parent received 173 (0xAD), difference -2
child wants to return 176 (0xB0), parent received 174 (0xAE), difference -2
child wants to return 177 (0xB1), parent received 175 (0xAF), difference -2
child wants to return 178 (0xB2), parent received 176 (0xB0), difference -2
child wants to return 179 (0xB3), parent received 177 (0xB1), difference -2
child wants to return 180 (0xB4), parent received 178 (0xB2), difference -2
child wants to return 181 (0xB5), parent received 179 (0xB3), difference -2
child wants to return 182 (0xB6), parent received 180 (0xB4), difference -2
child wants to return 183 (0xB7), parent received 181 (0xB5), difference -2
child wants to return 184 (0xB8), parent received 182 (0xB6), difference -2
child wants to return 185 (0xB9), parent received 183 (0xB7), difference -2
child wants to return 186 (0xBA), parent received 184 (0xB8), difference -2
child wants to return 187 (0xBB), parent received 185 (0xB9), difference -2
child wants to return 188 (0xBC), parent received 186 (0xBA), difference -2
child wants to return 189 (0xBD), parent received 187 (0xBB), difference -2
child wants to return 190 (0xBE), parent received 188 (0xBC), difference -2
child wants to return 191 (0xBF), parent received 189 (0xBD), difference -2
child wants to return 192 (0xC0), parent received 190 (0xBE), difference -2
(riscv-ilp32 chroot) farino /tmp #
===================
#include
#include
#include
#include
main(c, v)
int c;
char **v;
{
for(int z=0; z<255; z++){
pid_t pid, p;
int s, i, n;
s = 0;
pid = fork();
if (pid == 0)
exit(z);
/* wait for the process */
p = wait(&s);
if (p != pid)
exit (255);
if (WIFEXITED(s))
{
int r=WEXITSTATUS(s);
if (z!=r) {
printf("child wants to return %i (0x%X), parent received %i (0x%X),
difference %i\n",z,z,r,r,r-z);
}
}
}
}
===================
Am Montag, 14. September 2020, 11:14:16 EEST schrieb Andreas K. Hüttel:
> 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
> #include
> #include
> #include
>
> 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);
> 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] lists.gnu.org/archive/html/bug-bash/2020-09/msg00033.html
--
Andreas K. Hüttel
Gentoo Linux developer
(council, qa, toolchain, base-system, perl, libreoffice)
[Prev in Thread]
Current Thread
[Next in Thread]
Re: riscv32 wait() problem, qemu or glibc?,
Qemu devel<=