Use MAP_SHARED for read-only file mappings on MacOS and Android
Categories
(NSPR :: NSPR, defect, P1)
Tracking
(Not tracked)
People
(Reporter: jld, Assigned: jld)
References
Details
Attachments
(1 file)
1.63 KB,
patch
|
glandium
:
review+
|
Details | Diff | Splinter Review |
Both MacOS and Android have shared memory implementations that need to be mapped with MAP_SHARED
even for read-only use: POSIX shared memory on MacOS will return an error if mapped MAP_PRIVATE
, and Android's ashmem
will map zeroed memory instead of the memory object's contents in that case.
NSPR's PR_CreateFileMap
could be used with these forms of shared memory by importing the fd, except that it tries to use MAP_PRIVATE
for read-only mappings. There's already an #ifdef
ed workaround to use MAP_SHARED
in that case, for an old version of OSF/1, which could be extended to other OSes. That shouldn't affect regular file mappings, because the difference between MAP_SHARED
and MAP_PRIVATE
is the result of writes to the mapping, which aren't allowed in the read-only case.
Assignee | ||
Comment 1•6 years ago
|
||
Comment 2•6 years ago
|
||
Comment on attachment 9042329 [details] [diff] [review] bug1525803-nspr-shmem-hg0.diff Review of attachment 9042329 [details] [diff] [review]: ----------------------------------------------------------------- ::: pr/src/md/unix/unix.c @@ +3586,2 @@ > */ > fmap->md.flags = MAP_SHARED; Considering the POSIX definition of MAP_SHARED vs. MAP_PRIVATE say they only make a difference for modifications to the mapped data by the calling process, and considering PROT_READ is never going to allow modifications, I'm almost tempted to say we could make it MAP_SHARED everywhere. Anyways, I think it's fine like this.
Assignee | ||
Comment 3•6 years ago
|
||
I don't seem to have permission to push to NSPR.
Comment 4•6 years ago
|
||
Updated•5 years ago
|
Description
•