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

[3.14] gh-159739: Protect list storage while reporting its size (GH-160196) by miss-islington · Pull Request #160364 · 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 @@
Fix a race in ``list.__sizeof__()`` when a list is concurrently resized on a free-threaded build.
4 changes: 3 additions & 1 deletion Objects/listobject.c
Show comments Show annotations View file Open in desktop
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 @@ -137,7 +137,7 @@
py_list_resize(PyListObject *self, Py_ssize_t newsize)
{
size_t new_allocated, target_bytes;
Py_ssize_t allocated = self->allocated;

Check warning on line 140 in Objects/listobject.c

View workflow job for this annotation

GitHub Actions / Cross build Linux

unused variable ‘allocated’ [-Wunused-variable]

Check warning on line 140 in Objects/listobject.c

View workflow job for this annotation

GitHub Actions / Address sanitizer (ubuntu-26.04)

unused variable ‘allocated’ [-Wunused-variable]

Check warning on line 140 in Objects/listobject.c

View workflow job for this annotation

GitHub Actions / Ubuntu (installed) / build, install and test

unused variable ‘allocated’ [-Wunused-variable]

/* This over-allocates proportional to the list size, making room
* for additional growth. The over-allocation is mild, but is
Expand Down Expand Up @@ -3560,10 +3560,12 @@
{
size_t res = _PyObject_SIZE(Py_TYPE(self));
#ifdef Py_GIL_DISABLED
PyObject **ob_item = _Py_atomic_load_ptr(&self->ob_item);
Py_BEGIN_CRITICAL_SECTION(self);
PyObject **ob_item = self->ob_item;
if (ob_item != NULL) {
res += list_capacity(ob_item) * sizeof(PyObject *);
}
Py_END_CRITICAL_SECTION();
#else
res += (size_t)self->allocated * sizeof(PyObject *);
#endif
Expand Down
Loading

Back | FazBrowse Home | New Git URL