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
The _mmap_js implementation in syscalls.cpp has a TODO:
// TODO: handle non-private mmaps. Those can be optimized in interesting ways
// like avoiding an allocation and a copy as we do below (whereas a
// private mmap is always a copy into a new, private region not shared
// with anything else).
It also asserts that the flags contain MAP_PRIVATE. We don't need to fully address the optimizations in the TODO yet, but we do need to do better than asserting on MAP_SHARED.
We could support MAP_SHARED on MemoryFile in the simple case where it is not reallocated. That is basically what we supported in the old JS FS. Anything more would probably be quite hard, though.
Before working on this I'll try to collect data on how useful the limited form is. I'm not sure it's been used much in the old FS - we've normally recommended people to not use MAP_SHARED at all (and use features we can fully support).
Good find, @past-due! It looks like the implementation of __map_file also closes the file descriptor right after mapping, so in the current implementation that ties mappings to fds, there's no way that modifications can make it back to the file.
Activity
kripken commentedon Sep 6, 2022
We could support
MAP_SHAREDonMemoryFilein the simple case where it is not reallocated. That is basically what we supported in the old JS FS. Anything more would probably be quite hard, though.Before working on this I'll try to collect data on how useful the limited form is. I'm not sure it's been used much in the old FS - we've normally recommended people to not use
MAP_SHAREDat all (and use features we can fully support).past-due commentedon Sep 22, 2022
It looks like
MAP_SHAREDis used by__map_file, which is used by musl's gettext / libintl implementation:emscripten/system/lib/libc/musl/src/locale/dcngettext.c
Line 189 in e05e72d
So it is needed to load message catalogs.
tlively commentedon Sep 22, 2022
Good find, @past-due! It looks like the implementation of __map_file also closes the file descriptor right after mapping, so in the current implementation that ties mappings to fds, there's no way that modifications can make it back to the file.
tlively commentedon Feb 2, 2023
A couple users ran into mmap bugs on #15140.