Comments (4)
@tomjakubowski is exactly right. My current plan is to remove the Deref
and DerefMut
impls on Mmap
and replace it with a pair of methods:
unsafe fn as_slice(&self) -> &[u8];
unsafe fn as_mut_slice(&mut self) -> &[u8];
Additionally, I would like to add support for file locks (even if it is only advisory on POSIX systems) in order to have a runtime check of safety.
from memmap-rs.
What assumptions are broken? Seems fine to me. The mmaps of the same file have different lifetimes and the underlying semantics of how a mmap work are left to the user to consider.
from memmap-rs.
What assumptions are broken? Seems fine to me. The mmaps of the same file have different lifetimes and the underlying semantics of how a mmap work are left to the user to consider.
The compiler assumes that data behind a &T
, where T
does not contain UnsafeCell
, will not be changed for the lifetime of the reference. It also assumes that a &mut T
has exclusive access to its memory. If either of these assumptions are violated, then your program has undefined behavior.
Are data races confined to just shared mmaps, or do anonymous maps expose data races?
A child process can observe writes to shared, anonymous mmaps created by its parent, so I suspect that sticking to anonymous maps isn't sufficient. Maybe anonymous, private mmaps are free from data races.
from memmap-rs.
I think this issue is fixed. The state of the world is: accessing memory from a Mmap
requires an unsafe block, with the invariants clearly marked on the slicing methods (users should ensure that other processes or views are not accessing the memory concurrently). I'm going to punt on file locks, since that is outside the scope of this crate. If someone comes up with a good cross-platform flock interface, this could be used along with the Mmap
constructors that take a File
for additional runtime safety.
from memmap-rs.
Related Issues (20)
- Incorrectly uses usize instead of u64 for file offsets HOT 2
- Support madvise. HOT 4
- what happens if we exceed isize::MAX on 32-bit platforms? HOT 10
- Docs should say why file-backed maps are unsafe HOT 4
- Mmap fails for empty files on Windows HOT 21
- Allow mapping memory safely using `volatile` crate? HOT 4
- Use with DirectIO HOT 2
- Possible overflow while mapping large files on 32 bit systems HOT 1
- Add an `map_copy_read_only` API HOT 4
- Should anonymous mappings be MAP_SHARED by default?
- Allow anonymous RWX mappings HOT 1
- Implement StableDeref?
- Expose page_size pub function as part of crate api
- Support `Mmap` on platforms without real mmap support HOT 4
- Is this crate still maintained? HOT 15
- Error when mapping large files on Windows HOT 2
- Code 87 when attempting to write files HOT 1
- Handling IO-Errors during operation (which happen with network shares and connection drops) HOT 3
- ❌ mmap.binary_search EXC_BAD_ACCESS HOT 2
- Safety comments are missing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memmap-rs.