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

Jaikiran Pai jpai at openjdk.org
Mon Sep 1 10:19:41 UTC 2025


On Mon, 1 Sep 2025 05:31:43 GMT, Amit Kumar <amitkumar at openjdk.org> wrote:

> 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.

I think it's OK (and understandable) if the jtreg test doesn't reproduce a JVM crash itself. What would be good, is to have the same API call(s) with those relevant values being invoked from the jtreg test. It may be that we already have a jtreg test which exercises those values and if we are able to identify such an existing test then it would be good to mention it here or in the JBS issue and we won't have to introduce a new one.

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

PR Comment: https://git.openjdk.org/jdk/pull/27027#issuecomment-3241778603


More information about the core-libs-dev mailing list