forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 2
Changes made in sprint for PLDI deadline. #62
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 and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
451886c
Changes made in sprint for PLDI deadline.
mjp41 f50d40c
Addressing code review and CI failures.
mjp41 41c6bec
Format
mjp41 d965acf
Windows build
mjp41 2d6ce6f
More CI fixes
mjp41 15be839
More CI fixes
mjp41 b758039
Remove free-threaded build until we do that work.
mjp41 7f46141
Fix yaml lint (maybe)
mjp41 cdd4161
Disable another free threaded build
mjp41 684307d
Disable another free threaded build
mjp41 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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 |
|---|---|---|
|
|
@@ -18,30 +18,50 @@ extern int _PyModule_IsExtension(PyObject *obj); | |
|
|
||
| typedef struct { | ||
| PyObject_HEAD | ||
| // For immutable modules to find the mutable state and | ||
| // for logging purposes after md_dict is cleared | ||
| PyObject *md_name; | ||
| int md_frozen; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FIXME: @xFrednet, Investigate if this field can be avoided with the change of the Module object type as part of the pre-freeze hook. |
||
|
|
||
| // ******************************************************* | ||
| // Module state, only available on mutable module objects | ||
| // ******************************************************* | ||
| PyObject *md_dict; | ||
| PyModuleDef *md_def; | ||
| void *md_state; | ||
| PyObject *md_weaklist; | ||
| // for logging purposes after md_dict is cleared | ||
| PyObject *md_name; | ||
| #ifdef Py_GIL_DISABLED | ||
| void *md_gil; | ||
| #endif | ||
| } PyModuleObject; | ||
|
|
||
| PyAPI_FUNC(PyModuleObject*) _PyInterpreterState_GetModuleState(PyObject *mod); | ||
|
|
||
| static inline PyModuleDef* _PyModule_GetDef(PyObject *mod) { | ||
| assert(PyModule_Check(mod)); | ||
| return ((PyModuleObject *)mod)->md_def; | ||
| PyModuleObject *state = _PyInterpreterState_GetModuleState(mod); | ||
| if (state == NULL) { | ||
| return NULL; | ||
| } | ||
| return state->md_def; | ||
| } | ||
|
|
||
| static inline void* _PyModule_GetState(PyObject* mod) { | ||
| assert(PyModule_Check(mod)); | ||
| return ((PyModuleObject *)mod)->md_state; | ||
| PyModuleObject *state = _PyInterpreterState_GetModuleState(mod); | ||
| if (state == NULL) { | ||
| return NULL; | ||
| } | ||
| return state->md_state; | ||
| } | ||
|
|
||
| static inline PyObject* _PyModule_GetDict(PyObject *mod) { | ||
| assert(PyModule_Check(mod)); | ||
| PyObject *dict = ((PyModuleObject *)mod) -> md_dict; | ||
| PyModuleObject *state = _PyInterpreterState_GetModuleState(mod); | ||
| if (state == NULL) { | ||
| return NULL; | ||
| } | ||
| PyObject *dict = state -> md_dict; | ||
| // _PyModule_GetDict(mod) must not be used after calling module_clear(mod) | ||
| assert(dict != NULL); | ||
| return dict; // borrowed reference | ||
|
|
@@ -56,6 +76,8 @@ extern Py_ssize_t _PyModule_GetFilenameUTF8( | |
| PyObject* _Py_module_getattro_impl(PyModuleObject *m, PyObject *name, int suppress); | ||
| PyObject* _Py_module_getattro(PyObject *m, PyObject *name); | ||
|
|
||
| extern int _Py_module_freeze_hook(PyObject *m); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be part of the change set or is this an artifact of development/Debugging?
If this should be kept, it should be used for all
_MAXFREELISTvalues in this fileThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this useful for debugging memory safety issues with Asan. The freelists hide UAF and double-free that Asan would detect.
I think this is something that we could try to push into CPython for the sanitizer builds.
I am happy to drop from this PR. It isn't essential. I just would sooner not lose the code.