Skip to content

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

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

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

Conversation

@aisk
Copy link
Member

@aisk aisk commented Mar 5, 2026

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
Copy link
Member

vstinner commented Mar 5, 2026

cc @corona10

@corona10 corona10 self-assigned this Mar 5, 2026
Copy link
Member

@vstinner vstinner left a comment

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.

Copy link
Member

@corona10 corona10 left a comment

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
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