Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Bug report
Bug description:
Trying to narrow down what are 32-bit failures and what are i386 failures, I compiled Python 3.15.0b2 on FreeBSD 15.1-RC2 arm.armv7 and got these make test failures. This is the console log with colours removed, only showing the verbose mode output from re-runs, without those reported previously in #151007, #150984 or #150982.
Re-running test_wait3 in verbose mode (matching: test_wait3_rusage_initialized)
test_wait3_rusage_initialized (test.test_wait3.Wait3Test.test_wait3_rusage_initialized) ... FAIL
======================================================================
FAIL: test_wait3_rusage_initialized (test.test_wait3.Wait3Test.test_wait3_rusage_initialized)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/wrkdirs/usr/ports/lang/python315/work/Python-3.15.0b2/Lib/test/test_wait3.py", line 42, in test_wait3_rusage_initialized
self.assertEqual(0, status)
~~~~~~~~~~~~~~~~^^^^^^^^^^^
AssertionError: 0 != -65536
----------------------------------------------------------------------
Ran 1 test in 0.044s
FAILED (failures=1)
test test_wait3 failed
Re-running test.test_os.test_os in verbose mode (matching: test_headers_overflow_32bits, test_trailers_overflow_32bits)
test_headers_overflow_32bits (test.test_os.test_os.TestSendfile.test_headers_overflow_32bits) ... ERROR
test_trailers_overflow_32bits (test.test_os.test_os.TestSendfile.test_trailers_overflow_32bits) ... ERROR
======================================================================
ERROR: test_headers_overflow_32bits (test.test_os.test_os.TestSendfile.test_headers_overflow_32bits)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/wrkdirs/usr/ports/lang/python315/work/Python-3.15.0b2/Lib/asyncio/runners.py", line 127, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/wrkdirs/usr/ports/lang/python315/work/Python-3.15.0b2/Lib/asyncio/base_events.py", line 724, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/wrkdirs/usr/ports/lang/python315/work/Python-3.15.0b2/Lib/test/test_os/test_os.py", line 3792, in test_headers_overflow_32bits
self.server.handler_instance.accumulate = False
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Server' object has no attribute 'handler_instance'
======================================================================
ERROR: test_trailers_overflow_32bits (test.test_os.test_os.TestSendfile.test_trailers_overflow_32bits)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/wrkdirs/usr/ports/lang/python315/work/Python-3.15.0b2/Lib/asyncio/runners.py", line 127, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/wrkdirs/usr/ports/lang/python315/work/Python-3.15.0b2/Lib/asyncio/base_events.py", line 724, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/wrkdirs/usr/ports/lang/python315/work/Python-3.15.0b2/Lib/test/test_os/test_os.py", line 3801, in test_trailers_overflow_32bits
self.server.handler_instance.accumulate = False
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Server' object has no attribute 'handler_instance'
----------------------------------------------------------------------
Ran 2 tests in 0.048s
FAILED (errors=2)
test test.test_os.test_os failed
CPython versions tested on:
3.15
Operating systems tested on:
Other
Activity
vstinner commentedon Jun 8, 2026
test_headers_overflow_32bits() and test_trailers_overflow_32bits() are only run some operating systems (ex: not on Linux) and only on 32-bit systems. The last reference to
handler_instancewas in the commit 3ae975f replacing asyncore with asyncio in test_os.vstinner commentedon Jun 8, 2026
I managed to build Python on FreeBSD x64-64 in 32-bit using:
./configure --with-pydebug CFLAGS=-m32 LDFLAGS=-m32I had to disable extension modules which depend on C libraries (not available in 32-bit mode). I created
Modules/Setup.localwith the following contents:I wrote PR gh-151087 to fix test_os on 32-bit FreeBSD.
gh-151019: Fix test_os on 32-bit FreeBSD (#151087)
vstinner commentedon Jun 8, 2026
I'm unable to reproduce the test_wait3 issue with my setup.
mandree commentedon Jun 8, 2026
I am trying (have been for the past like hour or so) to debug this, though on a non-debug build.
What I can say is that
I would appreciate a pointer to example code how to emit debug information from Module/posixmodule.c. I tried fopen("filename", "w"), fopen("/tmp/filename", "w") but didn't ever see this attempt appear in truss, from os_wait3_impl. I'd just run "gmake -j40" top-level in the build directory and it seemed to re-build quite a few things, but I may need to install them, too for the test-suite? so ... gmake altinstall?
[3.13] gh-151019: Fix test_os on 32-bit FreeBSD (GH-151087) (#151095)
[3.14] gh-151019: Fix test_os on 32-bit FreeBSD (GH-151087) (#151094)
[3.15] gh-151019: Fix test_os on 32-bit FreeBSD (GH-151087) (#151093)
mandree commentedon Jun 8, 2026
EDIT: I am withdrawing this comment, see later comment for why.
I think the test_wait3 test is off and expecting that implementations behave in a certain way, OTOH wait3/wait4 interfaces are deprecated, so it's a bit like fighting history and may not be too useful going forward, and my proposal is if wait3() or wait4() came back without a PID, IOW no process reported status, to not only zero out the
struct rusagebut also thestatus, for consistency.The offending line of the test is marked below in Exhibit 1, and I am not sure that the original bug report bpo-36279 referenced by it https://bugs.python.org/issue36279 and the response are useful, 682107c but anyways, that's been there since Python 3.8 or so.
On FreeBSD and Linux; the documentation on wait3 or waitpid isn't perfectly clear on whether status is being filled in in case wait3(...WNOHANG...) returns 0 (which is a success), because no child had previously queued status from its termination or being stopped;
the waitid documentation on the respective OSes suggest that information isn't filled in (but waitid has a different return interface), and ARMv7 appears to be ... special, at least when running in emulation on an Aarch64 host.
PROPOSAL: The easy way to mask this idiosyncrasy is in the
wait_helper()place where we wipe out the rusage structure on pid == 0, to also zerostatus. The exit/signal status of something that doesn't exist isn't meaningful, so let's not pretend. With the patch shown in Exhibit 2, test_wait3 passes for me on the offending FreeBSD ARMv7 (running in a jail hosted on FreeBSD Aarch64).Exhibit 1, snipped from
Lib/tests/test_wait3.py:Exhibit 2, patch for
Module/posixmodule.c:[-]3.15.0b2 test failures on FreeBSD 15.1-RC2 arm.armv7[/-][+]3.15.0b2 test failures on FreeBSD 15.1-RC2 arm.armv7: test_os, test_wait3[/+]lang/python315: fix test_wait3 and test_os on armv7 and possibly else…
lang/python315: fix test_wait3 and test_os on armv7 and possibly else…
lang/python315: fix test_wait3 and test_os on armv7 and possibly else…
vstinner commentedon Jun 9, 2026
I'm not fully comfortable with changing wait_helper() if os.wait3() behavior is currently the same on all platforms tested by Python. Moreover, os.wait3() initializes the status to
0. At least, if you make this change, I would prefer to make it specific to FreeBSD and add a comment to explain that the bug occurs on armv7.mandree commentedon Jun 9, 2026
Understood, I re-read your comment, my comment, and the code, and have withdrawn my earlier statement that the test be off.
Let's instead put this to the FreeBSD-ARM guys to have a first look.
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295965 also has a shorter reproducer program that does not require the full Python.
Just to pick everyone up who joins this test debugging party late:
The current impression is that FreeBSD 15.1-RC2 on ARMv7 messes up the wait3(&status...) in the use case shown below, I added inline comments with //// so I can comment.
So we agree that at (1), Python essentially sets
status = 0(the whole macro decoration around that is for other systems that use a union and not a bit-masked integer, for process exit status codes) and (2) FreeBSD on certain combination of system and CPU/arch changes status to a 0xFFFF0000 bit pattern, which is -65536, and I read @vstinner's reaction such that this is odd and works most everywhere else.Direct permalink to code with explanatory source code comments:
cpython/Modules/posixmodule.c
Line 10513 in 94a64bb
vstinner commentedon Jun 10, 2026
Ok, so as I expected, it was a bug in the FreeBSD kernel. It just has been fixed in CURRENT: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=295965#c10.
I close this issue. I don't think that it's worth it to workaround this FreeBSD bug in the Python os module. You can carry a patch until the fix land in your kernel.
mandree commentedon Jun 10, 2026
Agreed. Thanks for insisting on finding the actual error location.
If I am reading the kernel fix right, it was in the 64-bit kernel's emulation layer that executes 32-bit code on 64-bit systems (and jails are somewhat thin separation in that they are not virtual machines, they share the host kernel), so might not even hit real 32-bit ARMv7 systems.
vstinner commentedon Jun 10, 2026
Correct. "real 32-bit ARMv7 systems" should not be affected.
pythongh-151019: Fix test_os on 32-bit FreeBSD (python#151087)