RFR: 8343984: Fix Unsafe address overflow [v2]

Per Minborg pminborg at openjdk.org
Tue Nov 12 08:47:48 UTC 2024


On Tue, 12 Nov 2024 08:26:44 GMT, Shaojin Wen <swen at openjdk.org> wrote:

>> In the JDK code, there are some places that may cause Unsafe offset overflow. The probability of occurrence is low, but if it occurs, it will cause JVM crash.
>
> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
> 
>   revert, from @minborg

It would be good to add some tests to ensure `long` precision is used.

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java line 1006:

> 1004:     }
> 1005: 
> 1006:     private void writeBooleanArray(TypeArray array, int length) throws IOException {

Note that the copyright year needs updating.

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java line 4104:

> 4102:     @ForceInline
> 4103:     static long byteArrayAddress(byte[] a, int index) {
> 4104:         return (long) Unsafe.ARRAY_BYTE_BASE_OFFSET + index;

These classes are generated via the `X-Vector.java.template` in the `java.incubator.vector` package.  So, you only need to change one file here.

![image](https://github.com/user-attachments/assets/2dbda48c-ae17-4809-a46f-62065ee9eab3)

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

PR Comment: https://git.openjdk.org/jdk/pull/22027#issuecomment-2469916847
PR Review Comment: https://git.openjdk.org/jdk/pull/22027#discussion_r1837687593
PR Review Comment: https://git.openjdk.org/jdk/pull/22027#discussion_r1837685399


More information about the core-libs-dev mailing list