RFR: 8366495: Incorrect minimum memory size allocated in allocateNativeInternal() [v2]

Amit Kumar amitkumar at openjdk.org
Tue Sep 2 09:43:23 UTC 2025


> Originally Reported in OpenJ9, fix by @AditiS11 present here: https://github.com/ibmruntimes/openj9-openjdk-jdk25/pull/32
> 
> These test failure were reported in OpenJ9 (x86), I can't reproduce on my system (s390x): 
> 
> java/foreign/TestFill.java
> java/foreign/TestSegments.java
> java/foreign/TestSegmentBulkOperationsContentHash.java
> java/foreign/TestStringEncoding.java
> java/foreign/TestVarArgs.java
> 
> 
> 
> ```java 
>         // Always allocate at least some memory so that zero-length segments have distinct
>         // non-zero addresses.
>         alignedSize = Math.max(1, alignedSize);
> 
> 
> Here minimum-allocated size will be 1, which is incorrect because 
> 
> 
>     private static void initNativeMemory(long address, long byteSize) {
>         for (long i = 0; i < byteSize; i += Long.BYTES) {
>             UNSAFE.putLongUnaligned(null, address + i, 0);
>         }
>     }
> 
> `initNativeMemory()` is going to write Long.

Amit Kumar has updated the pull request incrementally with one additional commit since the last revision:

  update

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/27027/files
  - new: https://git.openjdk.org/jdk/pull/27027/files/8bbef849..18c67d55

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=27027&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=27027&range=00-01

  Stats: 3 lines in 1 file changed: 1 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/27027.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/27027/head:pull/27027

PR: https://git.openjdk.org/jdk/pull/27027


More information about the core-libs-dev mailing list