This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: posix.sched_{get|set}affinity(-1) no longer returns ProcessLookup causing test failures on FreeBSD
Type: behavior Stage:
Components: FreeBSD, Tests Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, kj, koobs, miss-islington
Priority: normal Keywords: patch

Created on 2022-04-03 12:36 by christian.heimes, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 32285 merged christian.heimes, 2022-04-03 12:42
PR 32286 merged miss-islington, 2022-04-03 15:04
PR 32287 merged miss-islington, 2022-04-03 15:04
Messages (9)
msg416616 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2022-04-03 12:36
Two test cases have been failing on FreeBSD buildbot for a while. Let's skip the error check on FreeBSD for now.

0:27:24 load avg: 1.97 Re-running test_posix in verbose mode (matching: test_sched_getaffinity, test_sched_setaffinity)
test_sched_getaffinity (test.test_posix.PosixTester.test_sched_getaffinity) ... FAIL
test_sched_setaffinity (test.test_posix.PosixTester.test_sched_setaffinity) ... FAIL
======================================================================
FAIL: test_sched_getaffinity (test.test_posix.PosixTester.test_sched_getaffinity)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/buildbot/python/pull_request.koobs-freebsd-564d/build/Lib/test/test_posix.py", line 1197, in test_sched_getaffinity
    self.assertRaises(OSError, posix.sched_getaffinity, -1)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: OSError not raised by sched_getaffinity
======================================================================
FAIL: test_sched_setaffinity (test.test_posix.PosixTester.test_sched_setaffinity)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/buildbot/python/pull_request.koobs-freebsd-564d/build/Lib/test/test_posix.py", line 1215, in test_sched_setaffinity
    self.assertRaises(OSError, posix.sched_setaffinity, -1, mask)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: OSError not raised by sched_setaffinity
----------------------------------------------------------------------
Ran 2 tests in 0.015s
msg416620 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2022-04-03 13:38
Koobs, please take a look.
msg416621 - (view) Author: Ken Jin (kj) * (Python committer) Date: 2022-04-03 14:49
FWIW, seems like the buildbot started failing at either commit cb495a1e9f3acfcd8cb94a6b89c79d0909e3383f or 708812085355c92f32e547d1f1d1f29aefbbc27e. But I have no clue how commits changing the Windows build config can lead to test_posix failing.
msg416623 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2022-04-03 15:02
Koob's build bot is a FreeBSD 14 host. FreeBSD 14 is under development and has not reached stable yet. I bet that the issue was caused by a recent system and Kernel upgrade.
msg416624 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2022-04-03 15:04
New changeset b82cdd1dac9a9be52051abd90a1ce69236ac41f4 by Christian Heimes in branch 'main':
bpo-47205: Skip error check of sched_get/setaffinity on FreeBSD (GH-32285)
https://github.com/python/cpython/commit/b82cdd1dac9a9be52051abd90a1ce69236ac41f4
msg416627 - (view) Author: miss-islington (miss-islington) Date: 2022-04-03 15:30
New changeset 490ccbd6e0e5aad07a40c79a6b0c45ffca91724b by Miss Islington (bot) in branch '3.9':
bpo-47205: Skip error check of sched_get/setaffinity on FreeBSD (GH-32285)
https://github.com/python/cpython/commit/490ccbd6e0e5aad07a40c79a6b0c45ffca91724b
msg416640 - (view) Author: miss-islington (miss-islington) Date: 2022-04-03 19:27
New changeset 470dfe20cb6e741c42c52619e122fc218e27aebd by Miss Islington (bot) in branch '3.10':
bpo-47205: Skip error check of sched_get/setaffinity on FreeBSD (GH-32285)
https://github.com/python/cpython/commit/470dfe20cb6e741c42c52619e122fc218e27aebd
msg416647 - (view) Author: Kubilay Kocak (koobs) (Python triager) Date: 2022-04-04 00:29
Investigating
msg416830 - (view) Author: Kubilay Kocak (koobs) (Python triager) Date: 2022-04-05 23:05
From one of our base/kernel developers:

--------------------------------------------------------------

> koobs wrote:
>
> I don't grok the system call semantics, but it appears the issue is calls
> with the '-1' argument:
>
> mask = posix.sched_getaffinity(0)
> ...
> self.assertRaises(OSError, posix.sched_getaffinity, -1)
> ...
> self.assertRaises(OSError, posix.sched_setaffinity, -1, mask)
>
> This line was added 10 years ago in:
>
> https://github.com/python/cpython/commit/848698727fcbb633246b56ab57080b4d5493c186
>
> It wants an OSError [1] and presumably was getting it before recent
> failures, but isn't anymore:
>
> [1] https://docs.python.org/3/library/exceptions.html#OSError

So this is the difference:

Python 3.11.0a6+ (heads/main:38ae5b8c0c, Apr  5 2022, 03:27:23) [GCC 11.2.0] on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>>> import posix
>>> mask = posix.sched_getaffinity(-1)
>>> mask
{0, 1, 2, 3, 4, 5, 6, 7}

Python 3.10.4 (main, Mar 25 2022, 00:00:00) [GCC 11.2.1 20220127 (Red Hat 11.2.1-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import posix
>>> mask = posix.sched_getaffinity(-1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ProcessLookupError: [Errno 3] No such process

FreeBSD always accepted -1 as denoting the current process, while Linux
does not.  In fact, Linux uses 0 as current process pid alias.

For FreeBSD, both -1 and 0 works as getpid(), and I do not see it right
to break our traditional API conventions.  I believe the test should be
fixed.

--------------------------------------------------------------

I am not sure what changed between 3.10 and main that changed/removed
ProcessLookupError as the return for posix.sched_{get|set}affinity
with -1 as the argument, but that appears to be the cause of the current test failure
History
Date User Action Args
2022-04-11 14:59:58adminsetgithub: 91361
2022-04-05 23:07:44koobssettitle: test_sched_getaffinity and setaffinity fail on FreeBSD buildbit -> posix.sched_{get|set}affinity(-1) no longer returns ProcessLookup causing test failures on FreeBSD
2022-04-05 23:05:54koobssetmessages: + msg416830
2022-04-04 00:29:33koobssettype: behavior
messages: + msg416647
stage: patch review ->
2022-04-03 19:27:48miss-islingtonsetmessages: + msg416640
2022-04-03 15:30:53miss-islingtonsetmessages: + msg416627
2022-04-03 15:04:15christian.heimessetmessages: + msg416624
2022-04-03 15:04:13miss-islingtonsetpull_requests: + pull_request30348
2022-04-03 15:04:09miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request30347
2022-04-03 15:02:35christian.heimessetmessages: + msg416623
2022-04-03 14:49:16kjsetnosy: + kj
messages: + msg416621
2022-04-03 13:39:05christian.heimessetcomponents: + FreeBSD
2022-04-03 13:38:54christian.heimessetnosy: + koobs
messages: + msg416620
2022-04-03 12:42:23christian.heimessetkeywords: + patch
stage: patch review
pull_requests: + pull_request30346
2022-04-03 12:36:46christian.heimescreate