GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Expose annotation to anonymous virtual memory ranges to mmap module · Issue #142419 · python/cpython

Expose annotation to anonymous virtual memory ranges to mmap module #142419

New issue
Copy link
New issue
Copy link
Closed
Closed
Expose annotation to anonymous virtual memory ranges to mmap module#142419
Copy link
Assignees
corona10
Labels
extension-modulesC modules in the Modules dirC modules in the Modules dirtype-featureA feature request or enhancementA feature request or enhancement

Description

@corona10
corona10
opened on Dec 8, 2025
Issue body actions

Feature or enhancement

Proposal:

Since the annotation of anonymous virtual memory ranges has landed
(c4ccaf4),
We can now consider exposing this feature to end users as well.

#141770 (comment)

@encukou proposed adding a name parameter to mmap.mmap, and I think this would be a great addition.
It would make debugging much easier by allowing people to identify and track individual mmap allocations.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

#141770 (comment)

Linked PRs

  • gh-142419: Add mmap.set_name method for user custom annotation #142480

Activity

  1. corona10
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Dec 8, 2025
  2. corona10
    self-assigned this
    on Dec 8, 2025
  3. corona10 commented on Dec 8, 2025

    @corona10
    corona10
    on Dec 8, 2025
    MemberAuthor
    More actions

    cc @vstinner

  4. StanFromIreland
    added
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    on Dec 8, 2025
  5. SpecLad commented on Dec 8, 2025

    @SpecLad
    SpecLad
    on Dec 8, 2025
    Contributor
    More actions

    Since the underlying system call annotates an existing memory range, wouldn't it more natural for this to be a method call on the mmap object? E.g. mm = mmap.mmap(...); mm.set_name("foobar"). That way you could also change the name multiple times.

  6. vstinner commented on Dec 9, 2025

    @vstinner
    vstinner
    on Dec 9, 2025
    Member
    More actions

    I like the idea of a method. If prctl() fails, we can raise an exception. It allows ignoring the error in the caller. And it's easier to document that the method is only available on Linux 5.17 or newer.

    Reacted by Donghee Na
  7. corona10
    added 2 commits that reference this issue on Dec 9, 2025

    pythongh-142419: Add mmap.set_name method for annotation

    f19909e

    Merge remote-tracking branch 'upstream/main' into pythongh-142419

    c65e691
  8. encukou commented on Dec 10, 2025

    @encukou
    encukou
    on Dec 10, 2025
    Member
    More actions

    Another option would be doing the same thing as with thread names: add this as a Python name property (that is allow the get_name operation as well as the set_name), and do a "best effort" to synchronize it with the OS.

  9. vstinner commented on Dec 10, 2025

    @vstinner
    vstinner
    on Dec 10, 2025
    Member
    More actions

    Another option would be doing the same thing as with thread names: add this as a Python name property (that is allow the get_name operation as well as the set_name), and do a "best effort" to synchronize it with the OS.

    The threading module design requires to ignore silently errors which is not great :-( threading.py:

            try:
                _set_name(self._name)
            except OSError:
                pass
  10. encukou commented on Dec 10, 2025

    @encukou
    encukou
    on Dec 10, 2025
    Member
    More actions

    Yeah, because in that model you primarily set the Python property. This can store any string losslessly, so it's the preferred way to get the name back; it also works the same on all platforms.
    Syncing the OS-level annotation is then "just" for easier debugging. No guarantees there; data loss is expected -- full (incompatible OS) or partial (long strings, non-ASCII strings, embedded NULs, ...).

  11. SpecLad commented on Dec 10, 2025

    @SpecLad
    SpecLad
    on Dec 10, 2025
    Contributor
    More actions

    I don't think reading the name back from the OS makes much sense. I don't think Linux requires that the entire mmapped range have the same name - so 3rd-party code could set one name for the first half, and another name for the second half.

    It would also require parsing /proc/<pid>/maps, which seems rather pricey for a property read.

  12. SpecLad commented on Dec 10, 2025

    @SpecLad
    SpecLad
    on Dec 10, 2025
    Contributor
    More actions

    The threading module design requires to ignore silently errors which is not great :-(

    Honestly, given that this is mainly intended for debugging, I don't see what else one would do with an error other than silently ignore it. This feature seems inherently best-effort.

    Reacted by Petr Viktorin
  13. encukou commented on Dec 11, 2025

    @encukou
    encukou
    on Dec 11, 2025
    Member
    More actions

    I don't think reading the name back from the OS makes much sense.

    Yes. One of the nice things about the thread API is that you can get the name from the Python Thread object.

  14. corona10
    added 2 commits that reference this issue on Dec 17, 2025

    Merge pull request #65 from vstinner/pythongh-142419

    c78537b

    gh-142419: Add mmap.set_name method for user custom annotation (gh-14…

    14f0b51
  15. corona10
    closed this as completedon Dec 18, 2025
  16. cocolato
    added a commit that references this issue on Dec 18, 2025

    pythongh-142419: Add mmap.set_name method for user custom annotation (p…

    7f36dd3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @corona10
    corona10

Labels

extension-modulesC modules in the Modules dirC modules in the Modules dirtype-featureA feature request or enhancementA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.