Skip to content

RFC: win32: implement map from a file mapping object - #139

Open
elmarco wants to merge 3 commits into
RazrFalcon:masterfrom
elmarco:file-mapping
Open

RFC: win32: implement map from a file mapping object#139
elmarco wants to merge 3 commits into
RazrFalcon:masterfrom
elmarco:file-mapping

Conversation

@elmarco

@elmarco elmarco commented Jan 14, 2025

Copy link
Copy Markdown

Implement idea from #138

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Make it explicit that the kept handle is the file handle, not the
view for example.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
See:
RazrFalcon#138

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

@de-vri-es de-vri-es left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR!

Note that this is a breaking change for anyone who uses the MmapRawDescriptor directly.

Also, judging from the implementation, most of the actual work is skipped if you pass in a mapping handle.

What happens when the mmap options don't match the ones already set on the mapping handle? Will this lead to soundness issues? For example, can we end up giving a mutable slice to read-only memory?

I'm not 100% sure, but it feels like this use case can be better modeled by having an unsafe windows-only constructor directly on MmapMut/Mmap that also forces you to specify the length of the mapping. Something roughly like FromRawHandle, except we also need the mapping length.

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.

2 participants