https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295965
Bug ID: 295965
Summary: wait3(&status, WNOHANG, ...) clobbers status to -65536
when no child exits.
Product: Base System
Version: 15.1-RELEASE
Hardware: arm
URL: https://github.com/python/cpython/issues/151019#issuec
omment-4663777690
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: arm
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Created attachment 271653
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=271653&action=edit
test program to demonstrate ARMv7 wait3(WNOHANG) issue
Greetings,
we've been looking over various self-test failures in Python 3.15.0beta2 (in
ports) and on a particular system, and apparently FreeBSD 15.1-RC* clobber the
"status" field that we point wait3(...WNOHANG...) to when it doesn't have an
exited child to report the status of. See URL. The issue occurs in an ARMv7
poudriere jail hosted on Aarch64 on a Neoverse-N1 virtual server, and I can
reproduce it on Aarch64 with test code compiled with cc -m32.
int status = 0;
struct rusage ru; // uninit, will be cleared later if pid == 0
pid_t pid = wait3(&status, WNOHANG, &ru);
At this point, pid == 0 and status == -65536 on ARMv7 or with -m32, but not
Aarch64.
The latter is unexpected, and should be status = 0.
I am attaching a test program.
#0: It works on ARM64 and mostly everywhere else:
$ cc -std=c11 -o try try-wait3.c -O3 -Wall && ./try
pid = 0, status = 0 = 0
That's the expected outcome. wait3() has nothing to report, and leaves status
and ru alone.
#1: Now add -m32 to the command line:
$ cc -std=c11 -m32 -o try try-wait3.c -O3 -Wall && ./try
pid = 0, status = -65536 = 0xffff0000
=> OOPS.
To spice things up - truss "fixes" the status field but spoils the rusage
reporting:
$ truss ./try
fork() = 58606 (0xe4ee)
freebsd32_wait4(-1,{ EXITED,val=0 },WNOHANG,{
u=0.000000,s=0.000000,in=4294958518,out=-39440684688344 }) = 0 (0x0)
freebsd32_fstat(1,{ mode=crw--w---- ,inode=108,size=0,blksize=4096 }) = 0 (0x0)
freebsd32_mmap(0x0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0)
= 537174016 (0x2004a000)
[...]
freebsd32_mmap(0x0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0)
= 537210880 (0x20053000)
freebsd32_ioctl(1,TIOCGETA,0xffffcf68) = 0 (0x0)
pid = 0, status = 0 = 0
write(1,"pid = 0, status = 0 = 0\n",31) = 31 (0x1f)
kill(58606,SIGTERM) = 0 (0x0)
_exit(0x0)
process exit, rval = 0
The same happens if I set up an armv7 poudriere jail, enter it, and then
compile the test program there (with or without -m32 does not make a difference
obviously, the test fails every time unless run under truss).
--
You are receiving this mail because:
You are on the CC list for the bug.