From a8b35bf5a60c26e8975a468d4ebe6aac557e4d85 Mon Sep 17 00:00:00 2001 From: Axel Boldt-Christmas Date: Mon, 10 Nov 2025 05:53:55 +0000 Subject: [PATCH] 8367317: ZGC: ZVirtualMemoryReserver::force_reserve_discontiguous arithmetic underflow Reviewed-by: jsikstro, eosterlund --- src/hotspot/share/gc/z/zVirtualMemoryManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/z/zVirtualMemoryManager.cpp b/src/hotspot/share/gc/z/zVirtualMemoryManager.cpp index 2f81a5cfe09..aec54818a68 100644 --- a/src/hotspot/share/gc/z/zVirtualMemoryManager.cpp +++ b/src/hotspot/share/gc/z/zVirtualMemoryManager.cpp @@ -100,9 +100,10 @@ size_t ZVirtualMemoryReserver::force_reserve_discontiguous(size_t size) { if (reserve_contiguous(to_zoffset(reserve_start), reserve_size)) { reserved += reserve_size; + end -= reserve_size; } - end -= reserve_size * 2; + end -= MIN2(end, reserve_size); } // If (reserved < size) attempt to reserve the rest via normal divide and conquer