Content-Length: 286075 | pFad | https://github.com/python/cpython/pull/127659

58 [3.13] gh-127582: Make object resurrection thread-safe for free threading. (GH-127612) by colesbury · Pull Request #127659 · python/cpython · GitHub
Skip to content

[3.13] gh-127582: Make object resurrection thread-safe for free threading. (GH-127612)#127659

Merged
colesbury merged 1 commit intopython:3.13from
colesbury:backport-f4f5308-3.13
Dec 5, 2024
Merged

[3.13] gh-127582: Make object resurrection thread-safe for free threading. (GH-127612)#127659
colesbury merged 1 commit intopython:3.13from
colesbury:backport-f4f5308-3.13

Conversation

@colesbury
Copy link
Contributor

@colesbury colesbury commented Dec 5, 2024

Objects may be temporarily "resurrected" in destructors when calling finalizers or watcher callbacks. We previously undid the resurrection by decrementing the reference count using Py_SET_REFCNT. This was not thread-safe because other threads might be accessing the object (modifying its reference count) if it was exposed by the finalizer, watcher callback, or temporarily accessed by a racy dictionary or list access.

This adds internal-only thread-safe functions for temporary object resurrection during destructors.
(cherry picked from commit f4f5308)

… threading. (pythonGH-127612)

Objects may be temporarily "resurrected" in destructors when calling
finalizers or watcher callbacks. We previously undid the resurrection
by decrementing the reference count using `Py_SET_REFCNT`. This was not
thread-safe because other threads might be accessing the object
(modifying its reference count) if it was exposed by the finalizer,
watcher callback, or temporarily accessed by a racy dictionary or list
access.

This adds internal-only thread-safe functions for temporary object
resurrection during destructors.
(cherry picked from commit f4f5308)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/python/cpython/pull/127659

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy