bpo-32096: Statically initialize the default raw allocator. by ericsnowcurrently · Pull Request #4481 · python/cpython (original) (raw)
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation9 Commits5 Checks0 Files changed
Conversation
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
[ Show hidden characters]({{ revealButtonHref }})
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to a NEWS entry, it would be preferable to add an explicit test for this to _testembed.c
.
.initialized = 0, |
---|
.core_initialized = 0, |
// Py_DecodeLocale() relies on PyMem_RawMalloc() and PyMem_RawFree() |
// and may be needed before before runtime initialization. To allow |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doubled word "before before" in the comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.
Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again
. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.
For the explicit test, I'd suggest a dedicated one that just does:
ptr = Py_DecodeLocale();
Py_Initialize();
Py_Finalize();
PyMem_RawFree(ptr);
We can then consider adding equivalent tests for other "safe before Py_Initialize" APIs in https://bugs.python.org/issue32086
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, but I'm not entirely sure I understand the NEWS entry.
Unless the NEWS entry has typos in it, in which case it makes sense and just needs the typos fixed :)
have been crashing. This is because they rely on the raw memory allocator |
---|
having been initialized already. Before the runtime state change the |
default raw allocator was initialized statically. This has now been fixed |
by falling back to the defaults in PyMem_RawMalloc() and PyMem_RawFree(). |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the last two names here have underscore prefixes?
CI failure looks real though - my guess would be an allocator/deallocator mismatch due to Py_Finalize not explicitly reverting back to the default allocator.
This PR has been superseded by PR #4532, which reverts the mem-related globals consolidation. We will revisit a long-term solution later.