-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
gh-141770: Annotate anonymous mmap usage if "-X dev" is used #142079
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
35 commits
Select commit
Hold shift + click to select a range
0e3933d
gh-141770: Annotate anonymous mmap only for debug build
corona10 8b7023e
Apply annotation feature to modules
corona10 816d962
Add NEWS.d
corona10 979ce02
nit
corona10 b3d8547
Update Include/internal/pycore_pymem.h
corona10 0c5a495
Address code review
corona10 e757dd9
Address code review
corona10 cb9509b
Change annotation prefix
corona10 855742b
nit
corona10 32cc007
Address code review
corona10 49b4f95
Apply suggestions from code review
corona10 1b88b75
Address code review
corona10 e2eedbc
Address code review
corona10 a680677
test
corona10 8ec4d73
Add Include/internal/pycore_mmap.h
corona10 c0e08b6
fix
corona10 e66e650
Update PC
corona10 b0ca751
Update
corona10 c9138de
Update Whats News
corona10 8f77e0d
Merge remote-tracking branch 'upstream/main' into gh-141770
corona10 8706fce
Address code review
corona10 8ce8281
lint
corona10 d71a744
Update
corona10 4dd1ee4
Address code review
corona10 fee757e
Apply suggestions from code review
corona10 a240b3c
Update Objects/obmalloc.c
corona10 805c539
Address code review
corona10 795d31c
Update Misc/NEWS.d/next/Core_and_Builtins/2025-11-29-18-14-28.gh-issu…
corona10 be4d550
Address code review
corona10 290864a
Address code review
corona10 b287e0c
nit
corona10 1619f95
Update Misc/NEWS.d/next/Core_and_Builtins/2025-11-29-18-14-28.gh-issu…
corona10 a1ad592
Update Include/internal/pycore_mmap.h
corona10 e4e4835
Update Modules/_ctypes/malloc_closure.c
corona10 0429a0a
Update Include/internal/pycore_mmap.h
corona10 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #ifndef Py_INTERNAL_MMAP_H | ||
| #define Py_INTERNAL_MMAP_H | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| #ifndef Py_BUILD_CORE | ||
| # error "this header requires Py_BUILD_CORE define" | ||
| #endif | ||
|
|
||
| #include "pycore_pystate.h" | ||
|
|
||
| #if defined(HAVE_PR_SET_VMA_ANON_NAME) && defined(__linux__) | ||
| # include <linux/prctl.h> | ||
| # include <sys/prctl.h> | ||
| #endif | ||
|
|
||
| #if defined(HAVE_PR_SET_VMA_ANON_NAME) && defined(__linux__) | ||
| static inline void | ||
| _PyAnnotateMemoryMap(void *addr, size_t size, const char *name) | ||
| { | ||
| #ifndef Py_DEBUG | ||
| if (!_Py_GetConfig()->dev_mode) { | ||
| return; | ||
| } | ||
| #endif | ||
| assert(strlen(name) < 80); | ||
| int old_errno = errno; | ||
| prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)addr, size, name); | ||
| /* Ignore errno from prctl */ | ||
| /* See: https://bugzilla.redhat.com/show_bug.cgi?id=2302746 */ | ||
| errno = old_errno; | ||
| } | ||
| #else | ||
| static inline void | ||
| _PyAnnotateMemoryMap(void *Py_UNUSED(addr), size_t Py_UNUSED(size), const char *Py_UNUSED(name)) | ||
| { | ||
| } | ||
| #endif | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !Py_INTERNAL_MMAP_H |
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
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Core_and_Builtins/2025-11-29-18-14-28.gh-issue-141770.JURnvg.rst
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,2 @@ | ||
| Annotate anonymous mmap usage only when supported by the | ||
| Linux kernel and if ``-X dev`` is used or Python is built in debug mode. Patch by Donghee Na. |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.