JDK-8280940 : gtest os.release_multi_mappings_vm is racy
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 17,18,19
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-01-31
  • Updated: 2022-04-05
  • Resolved: 2022-02-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17 JDK 19
17.0.4Fixed 19 b10Fixed
Related Reports
Relates :  
Relates :  
Description
release_multi_mappings_vm, introduced as regression for JDK-8255978, is unfortunately racy.

The original intention of the test was to check that os::release_memory() works across multiple mappings allocated with multiple calls to os::reserve_memory(). This was broken for a long time on windows, since it relies on the implicit assumption that every platform uses mmap-ish APIs under the hood. But Windows virtual memory API (and SysV shmat, for that matter) does not work that way.

The release_multi_mappings_vm test

A reserves a number of mappings in 4M stripes adjacent to each other
B releases them with a single call to os::release_memory
C re-allocates a range at the same address
Step (C) will fail if the os::release call in (B) failed to release the mapping. Which it sometimes did silently, so just checking the return code in (B) was not sufficient.

Unfortunately, it will also fail if someone concurrently mapped into the range between (B) and (C). It's rare, but it happens.

This is difficult to make completely airtight, but we could make it much more stable:

instead of releasing all stripes, just release the n middle stripes (n>1) and leave first and last stripe reserved. Then, in (C), re-reserve the middle stripes. Tests the same (as long as we have multiple middle stripes) but drastically decreases the chance of some random allocation placing memory into the vacated address hole
reduce the stripe size from today's 4M to something much smaller. Again, reduces the chance of stray mappings being placed into the hole since it will be smaller too.

Comments
A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk17u-dev/pull/328 Date: 2022-04-01 05:37:53 +0000
01-04-2022

Fix Request (17): Fixes intermittent errors in multi-release gtest. Low risk. Does not apply cleanly; minor fixes were needed (needed include memTracker.hpp, and needed some resolving w/o resulting changes) Was reviewed, awaiting approval
01-04-2022

Changeset: f07b8165 Author: Thomas Stuefe <stuefe@openjdk.org> Date: 2022-02-14 16:41:47 +0000 URL: https://git.openjdk.java.net/jdk/commit/f07b8165231799383303e5c0755d07afd2feb7fd
14-02-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/7288 Date: 2022-01-31 12:20:58 +0000
03-02-2022

ILW = MLM = P4
01-02-2022