Details
-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
b18
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8279069 | 15.0.7 | Yuri Nesterenko | P4 | Resolved | Fixed | b01 |
Description
There's a code path through os::reserve_memory that uses MAP_FIXED. This path is used if a requested address is given.
It's very dangerous to use MAP_FIXED, since it causes preexisting mappings to be replaced.
Mac AARCH64 also can't use it in conjunction with MAP_JIT.
I started to split os::reserve_memory into two functions; one that doesn't care about were the memory is mapped, and another (os::reserve_memory_at) that uses the dangerous MAP_FIXED flag. However, I noticed that it's only windows code that actually use os::reserve_memory with a requested address. All other usages have been cleaned out and replaced with os::attempt_reserve_memory. And on windows os::attempt_reserve_memory uses os::reserve_memory with comments that it's safe because it only "attempts" to place the mapping.
So, this patch:
1) Removes the forcefully reserving of memory
2) Changes the windows code to call the attempt_reserve_memory verison, that it actually did anyway.
3) There's also some unification and split done to handle MEMFLAGS and fds. This part needs followup cleanups (IMHO).
It's very dangerous to use MAP_FIXED, since it causes preexisting mappings to be replaced.
Mac AARCH64 also can't use it in conjunction with MAP_JIT.
I started to split os::reserve_memory into two functions; one that doesn't care about were the memory is mapped, and another (os::reserve_memory_at) that uses the dangerous MAP_FIXED flag. However, I noticed that it's only windows code that actually use os::reserve_memory with a requested address. All other usages have been cleaned out and replaced with os::attempt_reserve_memory. And on windows os::attempt_reserve_memory uses os::reserve_memory with comments that it's safe because it only "attempts" to place the mapping.
So, this patch:
1) Removes the forcefully reserving of memory
2) Changes the windows code to call the attempt_reserve_memory verison, that it actually did anyway.
3) There's also some unification and split done to handle MEMFLAGS and fds. This part needs followup cleanups (IMHO).
Attachments
Issue Links
- backported by
-
JDK-8279069 Cleanup os::reserve_memory and remove MAP_FIXED
- Resolved
- duplicates
-
JDK-8079351 Remove req_addr parameter from os::reserve_memory()
- Closed
- relates to
-
JDK-8079351 Remove req_addr parameter from os::reserve_memory()
- Closed
- links to
-
Commit openjdk/jdk15u-dev/9a8cd1e6
-
Commit openjdk/jdk/625a9352
-
Review openjdk/jdk11u-dev/574
-
Review openjdk/jdk15u-dev/125
-
Review openjdk/jdk/357
(3 links to)