Skip to content

gh-116738: Make mmap.set_name thread-safe#145555

Merged
corona10 merged 3 commits into
python:mainfrom
aisk:mmap-set-name-thread-safe
Mar 7, 2026
Merged

gh-116738: Make mmap.set_name thread-safe#145555
corona10 merged 3 commits into
python:mainfrom
aisk:mmap-set-name-thread-safe

Conversation

@aisk

@aisk aisk commented Mar 5, 2026

Copy link
Copy Markdown
Member

mmap.resize may update the pointer to data and size, which is under the protection of a critical section.

In mmap.set_name, it uses data and size to annotate the mmap, but it does not have a critical section around it. So it may use an invalid data and size combination, which may have problems.

@vstinner

vstinner commented Mar 5, 2026

Copy link
Copy Markdown
Member

cc @corona10

@corona10 corona10 self-assigned this Mar 5, 2026
Comment thread Misc/NEWS.d/next/Core_and_Builtins/2026-03-06-01-36-20.gh-issue-116738.OWVWRx.rst Outdated

@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. It sounds reasonable to add a critical section to get a consistent view of the memory mapping.

@corona10 corona10 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!

@corona10 corona10 merged commit 46761c9 into python:main Mar 7, 2026
54 checks passed
@aisk aisk deleted the mmap-set-name-thread-safe branch March 8, 2026 02:37
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
* Add critical section around mmap.set_name to make it thread-safe

* Add news entry

* Apply suggestion from @aisk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants