You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, that's correct, and why it's unsafe. I don't think there's any way to avoid that potential with the shared resource of a file though, right? Probably the text should indicate this aspect of memory mapped files.
Probably the text should indicate this aspect of memory mapped files.
Yes, I think this needs a pretty big warning. Usually, I would assume that code in unsafe blocks does not invoke undefined behavior even though the compiler can't prove it.
I don't think there's any way to avoid that potential with the shared resource of a file though, right?
If there's no way to use the interface in a safe way, maybe it shouldn't be included in an extended standard library. The C function gets is also such a function that can't be used in a safe way, and it finally got removed after two standards, in C11.
I understand the perspective, but I do see memmap as something of a fundamental building block, and a tricky thing to get right cross-platform that I would rather people use an existing crate for. For now, I've at least added some color to the description about the futility of making memory mapping safe.
I think that the example in the
README.md
ofmemmap
contains a race condition which can lead to undefined behavior:If the file changes after the UTF-8 check, the program prints a
&str
that contains non-UTF-8 bytes.The text was updated successfully, but these errors were encountered: