FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-159739: Avoid leaking references during free-threaded GC enumeration by jelle-openai · Pull Request #159781 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix a reference leak in :func:`gc.get_objects` and :func:`gc.get_referrers`
when an internal allocation fails in the free-threaded build.
6 changes: 4 additions & 2 deletions Python/gc_free_threading.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2412,9 +2412,10 @@ visit_get_referrers(const mi_heap_t *heap, const mi_heap_area_t *area,
return true;
}
if (Py_TYPE(op)->tp_traverse(op, referrersvisit, arg->objs)) {
if (_PyObjectStack_Push(&arg->results, Py_NewRef(op)) < 0) {
if (_PyObjectStack_Push(&arg->results, op) < 0) {
return false;
}
Py_INCREF(op);
}

return true;
Expand Down Expand Up @@ -2459,9 +2460,10 @@ visit_get_objects(const mi_heap_t *heap, const mi_heap_area_t *area,
}

struct get_objects_args *arg = (struct get_objects_args *)args;
if (_PyObjectStack_Push(&arg->objects, Py_NewRef(op)) < 0) {
if (_PyObjectStack_Push(&arg->objects, op) < 0) {
return false;
}
Py_INCREF(op);
return true;
}

Expand Down
Loading

Back | FazBrowse Home | New Git URL