RFR: 8353564: Fail fatally if os::release_memory or os::uncommit_memory fails [v5]

Stefan Karlsson stefank at openjdk.org
Thu Jan 29 08:29:30 UTC 2026


On Thu, 29 Jan 2026 08:12:31 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> The patch uncovers a hidden error in ZGC tests. It uses `os::uncommit_memory` without checking the return type (ZForwardingTest::TearDown). It probably never worked before; now we assert. I actually like the new behavior better. Releasing not-matching memory ranges is dangerous (NMT would catch that too, though).
> 
> I think what happens here is that the underlying memory we operate on was reserved (in ZVirtualMemoryReserver -> ZVirtualMemoryReserverSmallPages::reserve -> ZMapper::reserve) via VirtualAlloc2, and that for whatever reason os::uncommit does not work here. Maybe the range does not match ? Or we need to call a different API.
> 
> I may be wrong, I did not look that closely. Maybe @stefank knows more.

Yes, but it was the os::commit work with ZGC's usage of VirtualAlloc2. There's a PR out for this:
https://github.com/openjdk/jdk/pull/29471

-------------

PR Comment: https://git.openjdk.org/jdk/pull/29240#issuecomment-3816211381


More information about the hotspot-dev mailing list