10000 [3.13] gh-130163: Fix crashes related to PySys_GetObject() (GH-130503) by serhiy-storchaka · Pull Request #130556 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.13] gh 10000 -130163: Fix crashes related to PySys_GetObject() (GH-130503) #130556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 25, 2025

Conversation

serhiy-storchaka
Copy link
Member
@serhiy-storchaka serhiy-storchaka commented Feb 25, 2025

The use of PySys_GetObject() and _PySys_GetAttr(), which return a borrowed reference, has been replaced by using one of the following functions, which return a strong reference and distinguish a missing attribute from an error: _PySys_GetOptionalAttr(), _PySys_GetOptionalAttrString(), _PySys_GetRequiredAttr(), and _PySys_GetRequiredAttrString(). (cherry picked from commit 0ef4ffe)

…honGH-130503)

The use of PySys_GetObject() and _PySys_GetAttr(), which return a borrowed
reference, has been replaced by using one of the following functions, which
return a strong reference and distinguish a missing attribute from an error:
_PySys_GetOptionalAttr(), _PySys_GetOptionalAttrString(),
_PySys_GetRequiredAttr(), and _PySys_GetRequiredAttrString().
(cherry picked from commit 0ef4ffe)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@serhiy-storchaka serhiy-storchaka merged commit 7c1b76f into python:3.13 Feb 25, 2025
37 checks passed
@miss-islington-app
Copy link

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 7c1b76fce8c8df00da38830f72dbdde6881a33be 3.12

@vstinner
Copy link
Member

This change introduced reference leaks in the 3.13 branch. Example:

$ ./python -m test test_genericalias -R 3:3
(...)
test_genericalias leaked [108, 108, 108] references, sum=324
(...)

cc @encukou

@vstinner
Copy link
Member

Example of buildbot failure, Fedora Stable (x86): https://buildbot.python.org/#/builders/1471/builds/551

Failed tests:

  • test_genericalias
  • test_ast
  • test_pickletools
  • test_typing

@serhiy-storchaka serhiy-storchaka deleted the backport-0ef4ffe-3.13 branch February 26, 2025 10:09
@serhiy-storchaka
Copy link
Member Author

Indeed, there is a leak in _pickle.c caused by mistake in backporting. Should be fixed by #130568. Thank you @vstinner for noticing.

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull request Feb 26, 2025
…honGH-130503) (pythonGH-130556)

The use of PySys_GetObject() and _PySys_GetAttr(), which return a borrowed
reference, has been replaced by using one of the following functions, which
return a strong reference and distinguish a missing attribute from an error:
_PySys_GetOptionalAttr(), _PySys_GetOptionalAttrString(),
_PySys_GetRequiredAttr(), and _PySys_GetRequiredAttrString().
(cherry picked from commit 0ef4ffe)
(cherry picked from commit 7c1b76f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-app
Copy link
bedevere-app bot commented Feb 26, 2025

GH-130576 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Feb 26, 2025
serhiy-storchaka added a commit that referenced this pull request Feb 26, 2025
GH-130556) (GH-130576)

The use of PySys_GetObject() and _PySys_GetAttr(), which return a borrowed
reference, has been replaced by using one of the following functions, which
return a strong reference and distinguish a missing attribute from an error:
_PySys_GetOptionalAttr(), _PySys_GetOptionalAttrString(),
_PySys_GetRequiredAttr(), and _PySys_GetRequiredAttrString().

(cherry picked from commit 0ef4ffe)
(cherry picked from commit 7c1b76f)
(cherry picked from commit 2ab7e11)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-free-threading type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0