Skip to content
Snippets Groups Projects
user avatar
Nadav Har'El authored
mprotect() is normally used on mmap()ed memory. It usually makes little
sense to for applications to mprotect() memory they got from malloc()ed,
for several reasons including the fact that free()ing this memory without
mprotect()ing it back to normal back is a recipe for big trouble (while
with munmap(), there is no need to mprotect() back). We therefore don't
expect Java to use mprotect() on malloc()ed memory.

For us, mprotect() on malloc() memory is particularly undesirable, because
malloc() returns addresses in the linear map, and mprotect()ing that can
"downgrade" this map (change huge pages into small pages) which will never
be fixed later, not even when if mprotect()ing the memory back to normal.
So for now, I'll just forbid mprotect() on addresses in the linear map.
4a6ec45e
History