Repository navigation
gh-151763: Fix crash in PyList_New() on allocation failure under low memory - #154019
Conversation
| } | ||
| else { | ||
| op->ob_item = NULL; | ||
| Py_SET_SIZE(op, 0); |
There was a problem hiding this comment.
The following two commands are safe, IIUC.
| Py_SET_SIZE(op, 0); | |
| op->allocated = 0; | |
| Py_SET_SIZE(op, size); |
There was a problem hiding this comment.
And then we can remove this Py_SET_SIZE.
8480542 to
cfee4d2
Compare
| else { | ||
| op->ob_item = NULL; | ||
| Py_SET_SIZE(op, size); | ||
| op->allocated = size; |
There was a problem hiding this comment.
No, main idea to set size here, and set allocated=size before GC track. allocated is a gate which stops readers from reading not initialized memory.
So, I propose something like:
op->ob_item = NULL;
op->allocated = 0;
Py_SET_SIZE(op, size);
// ...
// ...
op->allocated = size;
_PyObject_GC_TRACK(op);
There was a problem hiding this comment.
Ok! I have made the suggested changes. Thank you
|
Failing test (test_create_connection_local_addr_skip_different_family) seems unrelated to the change. |
|
I will see what the issue is |
|
The above CI failure has already been reported: gh-160334. We can wait for it to be resolved. |
|
GH-161785 is a backport of this pull request to the 3.15 branch. |
|
GH-161786 is a backport of this pull request to the 3.14 branch. |
…er low memory (GH-154019) (#161785) gh-151763: Fix crash in PyList_New() on allocation failure under low memory (GH-154019) (cherry picked from commit acab532) Co-authored-by: Abhishek Tiwari <[email protected]> Co-authored-by: Sergey Miryanov <[email protected]>
…er low memory (GH-154019) (#161786) gh-151763: Fix crash in PyList_New() on allocation failure under low memory (GH-154019) (cherry picked from commit acab532) Co-authored-by: Abhishek Tiwari <[email protected]> Co-authored-by: Sergey Miryanov <[email protected]>
…r low memory (python#154019) Co-authored-by: Sergey Miryanov <[email protected]>
Fixes gh-152125 (one of the OOM-injection fuzzing findings tracked under the gh-151763 umbrella).