classification
Title: os.sched_setaffinity does not handle errors during iteration.
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, brandtbucher, miss-islington
Priority: normal Keywords: patch

Created on 2019-06-26 22:22 by brandtbucher, last changed 2019-06-27 16:45 by miss-islington. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 14414 merged brandtbucher, 2019-06-26 22:22
PR 14425 merged miss-islington, 2019-06-27 16:11
PR 14426 merged miss-islington, 2019-06-27 16:11
Messages (4)
msg346691 - (view) Author: Brandt Bucher (brandtbucher) * (Python triager) Date: 2019-06-26 22:22
This is related to bpo-37417: os.sched_setaffinity doesn't properly handle errors that arise during iteration of the mask argument:

Python 3.9.0a0 (heads/master:d52a83a, Jun 26 2019, 15:13:41) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> bad_iter = map(int, "0X")
>>> os.sched_setaffinity(0, bad_iter)
ValueError: invalid literal for int() with base 10: 'X'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: <built-in function sched_setaffinity> returned a result with an error set

It looks like this bug is also present on all versions of Python 3. I've attached a patch with a fix and a regression test.
msg346751 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2019-06-27 16:11
New changeset 45a30af109f69a81576b87ea775863ba12d55316 by Benjamin Peterson (Brandt Bucher) in branch 'master':
closes bpo-37420: Handle errors during iteration in os.sched_setaffinity. (GH-14414)
https://github.com/python/cpython/commit/45a30af109f69a81576b87ea775863ba12d55316
msg346754 - (view) Author: miss-islington (miss-islington) Date: 2019-06-27 16:30
New changeset 65e187239a6feb09840ed9c2ebee51ed151e690d by Miss Islington (bot) in branch '3.7':
closes bpo-37420: Handle errors during iteration in os.sched_setaffinity. (GH-14414)
https://github.com/python/cpython/commit/65e187239a6feb09840ed9c2ebee51ed151e690d
msg346757 - (view) Author: miss-islington (miss-islington) Date: 2019-06-27 16:45
New changeset 6fbed5350c786ab88868925d67f59e19d0ab841c by Miss Islington (bot) in branch '3.8':
closes bpo-37420: Handle errors during iteration in os.sched_setaffinity. (GH-14414)
https://github.com/python/cpython/commit/6fbed5350c786ab88868925d67f59e19d0ab841c
History
Date User Action Args
2019-06-27 16:45:35miss-islingtonsetmessages: + msg346757
2019-06-27 16:30:53miss-islingtonsetnosy: + miss-islington
messages: + msg346754
2019-06-27 16:11:42miss-islingtonsetpull_requests: + pull_request14242
2019-06-27 16:11:22miss-islingtonsetpull_requests: + pull_request14241
2019-06-27 16:11:13benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg346751

resolution: fixed
stage: patch review -> resolved
2019-06-26 22:22:41brandtbuchersetkeywords: + patch
stage: patch review
pull_requests: + pull_request14226
2019-06-26 22:22:26brandtbuchercreate