RFR: 8375598: VM crashes with "assert((labs(val) & 0xFFFFFFFF00000000) == 0 || dest == (address)-1) failed: must be 32bit offset or -1" when using too high value for NonNMethodCodeHeapSize
Guanqiang Han
ghan at openjdk.org
Tue Jan 20 14:56:54 UTC 2026
Please review this change. Thanks!
**Description:**
On x86/x64, near calls/jumps use 32-bit signed PC-relative displacements. With SegmentedCodeCache enabled, a very large NonNMethodCodeHeapSize can inflate the derived ReservedCodeCacheSize, causing the code cache span to
exceed the reach of 32-bit relative branches. This may later lead to relocation failures (e.g. "must be 32bit offset") when installing nmethods.
https://github.com/openjdk/jdk/blob/037040129e82958bd023e0b24d962627e8653710/src/hotspot/cpu/x86/nativeInst_x86.hpp#L433-L440
**Fix:**
Add an x86-specific validation in CodeCache::initialize_heaps() after final segment alignment. If the computed code cache size exceeds max_jint bytes, abort VM initialization with a clear error message that includes the segment sizes, instead of failing later during compilation/relocation.
**Test:**
GHA
-------------
Commit messages:
- fix 8375598
Changes: https://git.openjdk.org/jdk/pull/29324/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29324&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8375598
Stats: 23 lines in 2 files changed: 20 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/29324.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/29324/head:pull/29324
PR: https://git.openjdk.org/jdk/pull/29324
More information about the hotspot-compiler-dev
mailing list