From 5672dc47a6e6f4ee4239c2316818544140db47d8 Mon Sep 17 00:00:00 2001 From: Benshuai5D Date: Tue, 15 Jul 2025 20:11:55 +0800 Subject: [PATCH] 8296924: C2: assert(is_valid_AArch64_address(dest.target())) failed: bad address --- ...t-is_valid_AArch64_address-dest.targ.patch | 100 ++++++++++++++++++ openjdk-1.8.0.spec | 7 +- 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 Backport-8296924-C2-assert-is_valid_AArch64_address-dest.targ.patch diff --git a/Backport-8296924-C2-assert-is_valid_AArch64_address-dest.targ.patch b/Backport-8296924-C2-assert-is_valid_AArch64_address-dest.targ.patch new file mode 100644 index 0000000..335696b --- /dev/null +++ b/Backport-8296924-C2-assert-is_valid_AArch64_address-dest.targ.patch @@ -0,0 +1,100 @@ +Subject: [PATCH] 8296924: C2: assert(is_valid_AArch64_address(dest.target())) + failed: bad address + +--- + hotspot/src/cpu/aarch64/vm/aarch64.ad | 15 ++--- + .../compiler/unsafe/TestBadBaseAddress.java | 56 +++++++++++++++++++ + 2 files changed, 64 insertions(+), 7 deletions(-) + create mode 100644 hotspot/test/compiler/unsafe/TestBadBaseAddress.java + +diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad +index 347c29263..eb6a50241 100644 +--- a/hotspot/src/cpu/aarch64/vm/aarch64.ad ++++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad +@@ -3022,13 +3022,14 @@ encode %{ + __ mov_metadata(dst_reg, (Metadata*)con); + } else { + assert(rtype == relocInfo::none, "unexpected reloc type"); +- if (con < (address)(uintptr_t)os::vm_page_size()) { +- __ mov(dst_reg, con); +- } else { +- unsigned long offset; +- __ adrp(dst_reg, con, offset); +- __ add(dst_reg, dst_reg, offset); +- } ++ if (! __ is_valid_AArch64_address(con) || ++ con < (address)(uintptr_t)os::vm_page_size()) { ++ __ mov(dst_reg, con); ++ } else { ++ unsigned long offset; ++ __ adrp(dst_reg, con, offset); ++ __ add(dst_reg, dst_reg, offset); ++ } + } + } + %} +diff --git a/hotspot/test/compiler/unsafe/TestBadBaseAddress.java b/hotspot/test/compiler/unsafe/TestBadBaseAddress.java +new file mode 100644 +index 000000000..4520d5b54 +--- /dev/null ++++ b/hotspot/test/compiler/unsafe/TestBadBaseAddress.java +@@ -0,0 +1,56 @@ ++/* ++ * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ */ ++ ++/** ++ * @test ++ * @bug 8296924 ++ * @summary Tests compilation of an unreachable unsafe access with a bad base address. ++ * @run main/othervm -XX:CompileCommand=compileonly,TestBadBaseAddress::test -XX:-TieredCompilation -Xcomp TestBadBaseAddress ++ */ ++ ++import java.lang.reflect.*; ++import sun.misc.*; ++ ++public class TestBadBaseAddress { ++ private static Unsafe unsafe; ++ ++ static { ++ try { ++ Field field = Unsafe.class.getDeclaredField("theUnsafe"); ++ field.setAccessible(true); ++ unsafe = (Unsafe)field.get(null); ++ } catch (Exception e) { ++ throw new RuntimeException(e); ++ } ++ } ++ ++ public static void test(boolean b) { ++ if (b) { ++ unsafe.putLong(-1, 42); ++ } ++ } ++ ++ public static void main(String[] args) { ++ test(false); ++ } ++} +-- +2.34.1 + diff --git a/openjdk-1.8.0.spec b/openjdk-1.8.0.spec index 2005a4f..9d4b7d7 100644 --- a/openjdk-1.8.0.spec +++ b/openjdk-1.8.0.spec @@ -953,7 +953,7 @@ Provides: java-%{javaver}-%{origin}-accessibility%{?1} = %{epoch}:%{version}-%{r Name: java-%{javaver}-%{origin} Version: %{javaver}.%{updatever}.%{buildver} -Release: 8 +Release: 9 # java-1.5.0-ibm from jpackage.org set Epoch to 1 for unknown reasons # and this change was brought into RHEL-4. java-1.5.0-ibm packages # also included the epoch in their virtual provides. This created a @@ -1381,6 +1381,7 @@ Patch466: jprofilecache-should-set-log-permission.patch Patch467: set-JProfilecache-feature-experimental.patch Patch468: 8151920-Region-liveness-printing-is-broken.patch Patch469: huawei-AArch64-Incorrect-matching-rule.patch +Patch470: Backport-8296924-C2-assert-is_valid_AArch64_address-dest.targ.patch ############################################# # @@ -2068,6 +2069,7 @@ pushd %{top_level_dir_name} %patch467 -p1 %patch468 -p1 %patch469 -p1 +%patch470 -p1 %endif %ifarch loongarch64 @@ -3054,6 +3056,9 @@ cjc.mainProgram(args) -- the returns from copy_jdk_configs.lua should not affect %endif %changelog +* Tue July 15 2025 Benshuai5D -1:1.8.0.452.b09-9 +- add Backport-8296924-C2-assert-is_valid_AArch64_address-dest.targ.patch + * Tue July 15 2025 DXwangg -1:1.8.0.452.b09-8 - add huawei-AArch64-Incorrect-matching-rule.patch -- Gitee