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

gh-105375: Explicitly initialise all {Pickler,Unpickler}Object fields by erlend-aasland · Pull Request #105686 · python/cpython · GitHub

Repository navigation

gh-105375: Explicitly initialise all {Pickler,Unpickler}Object fields - #105686

Merged
erlend-aasland merged 2 commits into
python:mainfrom
erlend-aasland:fix-gh-105475
Jun 12, 2023
Merged

erlend-aasland merged 2 commits into
python:mainfrom
erlend-aasland:fix-gh-105475

Conversation

erlend-aasland commented Jun 12, 2023 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Contributor

PyObject_GC_New() only initialises the object header. All other fields
must be explicitly initialised to prevent manipulation of uninitialised
fields in dealloc.

Align initialisation order with the layout of the object structs.

…fields

PyObject_GC_New() only initialises the object header. All other fields
must be explicitly initialised to prevent manipulation of uninitialised
fields in dealloc.

Align initialisation order with the layout of the object structs.
- Prepare memory allocations and new objects before calling PyObject_GC_New()
- Initialise all fields at once using a series of assignments only
- Use error labels for clarity

serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think that it is enough to set output_buffer = NULL.

Copy link
Copy Markdown
Contributor Author

I think that it is enough to set output_buffer = NULL.

You also need to adjust _Unpickler_New(): The minimal solution is setting self->output_buffer = NULL and also for example self->stack = NULL in _Unpickler_New(). I still think this PR is better, since it makes for cleaner error handling and improved maintainability. I'm not going to push it, though; I can live with the minimal solution :)

Copy link
Copy Markdown
Contributor

Thanks @erlend-aasland for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

erlend-aasland deleted the fix-gh-105475 branch June 12, 2023 21:35

Copy link
Copy Markdown
Contributor

Sorry, @erlend-aasland, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker ca3cc4b95d66f7527ebe0ba4cdb1907082d9bfc8 3.11

Copy link
Copy Markdown

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 12, 2023
…fields (pythonGH-105686)

All fields must be explicitly initialised to prevent manipulation of
uninitialised fields in dealloc.

Align initialisation order with the layout of the object structs.
(cherry picked from commit ca3cc4b)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
bedevere-bot removed the needs backport to 3.12 only security fixes label Jun 12, 2023
erlend-aasland added a commit to erlend-aasland/cpython that referenced this pull request Jun 12, 2023
…Object fields (python#105686)

All fields must be explicitly initialised to prevent manipulation of
uninitialised fields in dealloc.

Align initialisation order with the layout of the object structs.

(cherry picked from commit ca3cc4b)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>

Copy link
Copy Markdown

GH-105711 is a backport of this pull request to the 3.11 branch.

bedevere-bot removed the needs backport to 3.11 only security fixes label Jun 12, 2023

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

erlend-aasland added a commit that referenced this pull request Jun 12, 2023
… fields (GH-105686) (#105710)

All fields must be explicitly initialised to prevent manipulation of
uninitialised fields in dealloc.

Align initialisation order with the layout of the object structs.

(cherry picked from commit ca3cc4b)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
carljm added a commit to carljm/cpython that referenced this pull request Jun 12, 2023
* main:
  pythongh-105540: Fix code generator tests (python#105707)
  pythongh-105375: Explicitly initialise all {Pickler,Unpickler}Object fields (python#105686)
  pythongh-105331: Change `asyncio.sleep` to raise ``ValueError` for nan (python#105641)
  Remove support for legacy bytecode instructions (python#105705)
kumaraditya303 pushed a commit that referenced this pull request Jun 13, 2023
… fields (#105686) (#105711)

* [3.11] gh-105375: Explicitly initialise all {Pickler,Unpickler}Object fields (#105686)

All fields must be explicitly initialised to prevent manipulation of
uninitialised fields in dealloc.

Align initialisation order with the layout of the object structs.

(cherry picked from commit ca3cc4b)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL