Skip to content

gh-141770: Annotate anonymous mmap usage if "-X dev" is used - #142079

Merged
corona10 merged 35 commits into
python:mainfrom
corona10:gh-141770
Dec 8, 2025
Merged

corona10 merged 35 commits into
python:mainfrom
corona10:gh-141770

Conversation

@corona10

@corona10 corona10 commented Nov 29, 2025 •

Copy link
Copy Markdown
Member
@corona10

corona10 commented Nov 29, 2025 •

Copy link
Copy Markdown
Member Author

Annotation

Screenshot 2025-11-29 at 6 10 03 PM

Without annotation

Screenshot 2025-11-29 at 6 23 31 PM

I verified that this annotation actually works, and I believe it will be very helpful for debugging when needed.

@corona10

Copy link
Copy Markdown
Member Author
@corona10

Copy link
Copy Markdown
Member Author

FYI, Fedora does not support yet even if the kernel version itself already support it.
See: https://bugzilla.redhat.com/show_bug.cgi?id=2302746

cc @vstinner @encukou

Comment thread Include/internal/pycore_pymem.h Resolved
Comment thread Include/internal/pycore_pymem.h Resolved
corona10 and others added 3 commits November 29, 2025 09:30
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@corona10
corona10 requested a review from picnixz November 29, 2025 10:13
Comment thread Include/internal/pycore_pymem.h Resolved
@SpecLad

SpecLad commented Nov 29, 2025

Copy link
Copy Markdown
Contributor

FWIW, it would be useful to have an option to enable this in release builds too.

@corona10

Copy link
Copy Markdown
Member Author

@SpecLad Thanks for the feedback, I will create a separate PR :)

@corona10

Copy link
Copy Markdown
Member Author

@SpecLad Just out of curiosity, passing the build flag through ./configure --enable-annotate-mmap would be fine to you?
I would like to follow Ruby's approach but disable this flag by default unless many disto actually want this flag.

@SpecLad

SpecLad commented Nov 29, 2025

Copy link
Copy Markdown
Contributor

To be clear, by "option" I really mean a runtime option. 🙂 It would be pretty annoying to have to rebuild Python just for this. If you compare with other implementations, none of them require a compile-time option:

  • C (glibc) - off by default, can be enabled with environment variable;
  • Go - on by default, can be disabled with environment variable;
  • Ruby - on permanently (unless I missed something).

TBH, I don't see why Python shouldn't also permanently enable this, but I would settle for "off by default, enabled with environment variable or -X option".

@picnixz

picnixz commented Nov 29, 2025

Copy link
Copy Markdown
Member

It's a bit annoying that this would only be supported on Linux. Do we have an option that isn't supported everywhere?

corona10 and others added 3 commits December 5, 2025 23:03
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
@corona10
corona10 requested a review from vstinner December 5, 2025 14:08

@corona10 corona10 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@vstinner @picnixz I 've applied all your suggestion.

Comment thread Doc/whatsnew/3.15.rst Outdated
modules that are missing or packaged separately.
(Contributed by Stan Ulbrych and Petr Viktorin in :gh:`139707`.)

* Annotating anonymous mmap usage is now supported if Linux kernel supports ``PR_SET_VMA_ANON_NAME`` (Linux 5.17 or newer).

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.

* Annotating anonymous mmap usage is now supported if Linux kernel
  supports :manpage:`PR_SET_VMA_ANON_NAME <PR_SET_VMA(2const)>`
  (Linux 5.17 or newer).

I don't know under which manpage entry it is, but if you locally run Sphinx, you should be able to find the correct one. That way, users would have a link to click on. If there isn't a manpage, nevermind.

Comment thread Include/internal/pycore_mmap.h Resolved
corona10 and others added 4 commits December 6, 2025 00:42
…e-141770.JURnvg.rst

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
…e-141770.JURnvg.rst

Co-authored-by: Victor Stinner <vstinner@python.org>
Comment thread Include/internal/pycore_mmap.h Resolved
corona10 and others added 2 commits December 8, 2025 23:09
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>

@vstinner vstinner 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.

LGTM

Comment thread Include/internal/pycore_mmap.h Resolved
Co-authored-by: Victor Stinner <vstinner@python.org>
@corona10
corona10 enabled auto-merge (squash) December 8, 2025 14:20
@corona10
corona10 merged commit c4ccaf4 into python:main Dec 8, 2025
@corona10
corona10 deleted the gh-141770 branch December 8, 2025 14:51
@bedevere-bot

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Ubuntu Shared 3.x (tier-1) has failed when building commit c4ccaf4.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/506/builds/11950) and take a look at the build logs.
  4. Check if the failure is related to this commit (c4ccaf4) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/506/builds/11950

Failed tests:

  • test_sys
  • test_audit
  • test_profiling
  • test_external_inspection
  • test_remote_pdb

Failed subtests:

  • test_sys_remote_exec - test.test_audit.AuditTest.test_sys_remote_exec

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_audit.py", line 332, in test_sys_remote_exec
    self.fail(stderr)
    ~~~~~~~~~^^^^^^^^
AssertionError: Fatal Python error: _Py_CheckFunctionResult: a function returned a result with an exception set
Python runtime state: initialized
OSError: Cannot open ELF file '[anon:cpython:pymalloc]' for section 'PyRuntime' search: No such file or directory
@hugovk

hugovk commented Dec 10, 2025

Copy link
Copy Markdown
Member

Please can you check the buildbot failure?

hugovk added a commit to hugovk/cpython that referenced this pull request Dec 10, 2025
@hugovk

hugovk commented Dec 11, 2025 •

Copy link
Copy Markdown
Member

I think it's a problem with the buildbot machine: it's timing out on other branches now, and the builds are taking nearly five hours, when they used to take around 50 minutes:

https://buildbot.python.org/#/workers/31

@vstinner

vstinner commented Dec 11, 2025 •

Copy link
Copy Markdown
Member

I just sent an email to David Bolen (the buildbot owner) to ask him to have a look. Something seems to be wrong with this buildbot worker.

@vstinner

Copy link
Copy Markdown
Member

This change introduced a regression: #142627.

@vstinner

Copy link
Copy Markdown
Member

Note for myself: The feature is not available on Fedora, since Fedora builds the Linux kernel without the CONFIG_ANON_VMA_NAME option:

$ grep CONFIG_ANON_VMA_NAME /boot/config-$(uname -r)
# CONFIG_ANON_VMA_NAME is not set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

8 participants