diff --git a/Backport-JDK-7036144-GZIPInputStream-readTrailer-use.patch b/Backport-JDK-7036144-GZIPInputStream-readTrailer-use.patch new file mode 100644 index 0000000000000000000000000000000000000000..b9dad132eaf6cfdf048cfca7eda8279209e3636f --- /dev/null +++ b/Backport-JDK-7036144-GZIPInputStream-readTrailer-use.patch @@ -0,0 +1,148 @@ +Subject: [PATCH] Backport JDK-8337393: GZIPInputStream readTrailer uses faulty + available() test for end-of-stream + +--- + .../java/util/zip/GZIPInputStream.java | 24 ++--- + .../zip/GZIP/GZIPInputStreamAvailable.java | 93 +++++++++++++++++++ + 2 files changed, 102 insertions(+), 15 deletions(-) + create mode 100644 test/jdk/java/util/zip/GZIP/GZIPInputStreamAvailable.java + +diff --git a/src/java.base/share/classes/java/util/zip/GZIPInputStream.java b/src/java.base/share/classes/java/util/zip/GZIPInputStream.java +index 850691e02..ad819e271 100644 +--- a/src/java.base/share/classes/java/util/zip/GZIPInputStream.java ++++ b/src/java.base/share/classes/java/util/zip/GZIPInputStream.java +@@ -260,23 +260,17 @@ public class GZIPInputStream extends InflaterInputStream { + (readUInt(in) != (inf.getBytesWritten() & 0xffffffffL))) + throw new ZipException("Corrupt GZIP trailer"); + +- // If there are more bytes available in "in" or +- // the leftover in the "inf" is > 26 bytes: +- // this.trailer(8) + next.header.min(10) + next.trailer(8) + // try concatenated case +- if (this.in.available() > 0 || n > 26) { +- int m = 8; // this.trailer +- try { +- m += readHeader(in); // next.header +- } catch (IOException ze) { +- return true; // ignore any malformed, do nothing +- } +- inf.reset(); +- if (n > m) +- inf.setInput(buf, len - n + m, n - m); +- return false; ++ int m = 8; // this.trailer ++ try { ++ m += readHeader(in); // next.header ++ } catch (IOException ze) { ++ return true; // ignore any malformed, do nothing + } +- return true; ++ inf.reset(); ++ if (n > m) ++ inf.setInput(buf, len - n + m, n - m); ++ return false; + } + + /* +diff --git a/test/jdk/java/util/zip/GZIP/GZIPInputStreamAvailable.java b/test/jdk/java/util/zip/GZIP/GZIPInputStreamAvailable.java +new file mode 100644 +index 000000000..1468c104f +--- /dev/null ++++ b/test/jdk/java/util/zip/GZIP/GZIPInputStreamAvailable.java +@@ -0,0 +1,93 @@ ++/* ++ * Copyright (c) 2023, 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 7036144 ++ * @summary Test concatenated gz streams when available() returns zero ++ * @run junit GZIPInputStreamAvailable ++ */ ++ ++import org.junit.jupiter.api.Test; ++ ++import java.io.*; ++import java.util.*; ++import java.util.zip.*; ++ ++import static org.junit.jupiter.api.Assertions.assertArrayEquals; ++ ++public class GZIPInputStreamAvailable { ++ ++ public static final int NUM_COPIES = 100; ++ ++ @Test ++ public void testZeroAvailable() throws IOException { ++ ++ // Create some uncompressed data and then repeat it NUM_COPIES times ++ byte[] uncompressed1 = "this is a test".getBytes("ASCII"); ++ byte[] uncompressedN = repeat(uncompressed1, NUM_COPIES); ++ ++ // Compress the original data and then repeat that NUM_COPIES times ++ byte[] compressed1 = deflate(uncompressed1); ++ byte[] compressedN = repeat(compressed1, NUM_COPIES); ++ ++ // (a) Read back inflated data from a stream where available() is accurate and verify ++ byte[] readback1 = inflate(new ByteArrayInputStream(compressedN)); ++ assertArrayEquals(uncompressedN, readback1); ++ ++ // (b) Read back inflated data from a stream where available() always returns zero and verify ++ byte[] readback2 = inflate(new ZeroAvailableStream(new ByteArrayInputStream(compressedN))); ++ assertArrayEquals(uncompressedN, readback2); ++ } ++ ++ public static byte[] repeat(byte[] data, int count) { ++ byte[] repeat = new byte[data.length * count]; ++ int off = 0; ++ for (int i = 0; i < count; i++) { ++ System.arraycopy(data, 0, repeat, off, data.length); ++ off += data.length; ++ } ++ return repeat; ++ } ++ ++ public static byte[] deflate(byte[] data) throws IOException { ++ ByteArrayOutputStream buf = new ByteArrayOutputStream(); ++ try (GZIPOutputStream out = new GZIPOutputStream(buf)) { ++ out.write(data); ++ } ++ return buf.toByteArray(); ++ } ++ ++ public static byte[] inflate(InputStream in) throws IOException { ++ return new GZIPInputStream(in).readAllBytes(); ++ } ++ ++ public static class ZeroAvailableStream extends FilterInputStream { ++ public ZeroAvailableStream(InputStream in) { ++ super(in); ++ } ++ @Override ++ public int available() { ++ return 0; ++ } ++ } ++} +-- +2.48.1 + diff --git a/Backport-JDK-8314236-Overflow-in-Collections.rotate.patch b/Backport-JDK-8314236-Overflow-in-Collections.rotate.patch new file mode 100644 index 0000000000000000000000000000000000000000..a11b6c0ec754d5604eca3263e4f8bdc6b040b889 --- /dev/null +++ b/Backport-JDK-8314236-Overflow-in-Collections.rotate.patch @@ -0,0 +1,125 @@ +Subject: [PATCH] Backport JDK-8314236: Overflow in Collections.rotate + +--- + .../share/classes/java/util/Collections.java | 9 +- + .../jdk/java/util/Collections/RotateHuge.java | 83 +++++++++++++++++++ + 2 files changed, 88 insertions(+), 4 deletions(-) + create mode 100644 test/jdk/java/util/Collections/RotateHuge.java + +diff --git a/src/java.base/share/classes/java/util/Collections.java b/src/java.base/share/classes/java/util/Collections.java +index f45d297f3..63949db2c 100644 +--- a/src/java.base/share/classes/java/util/Collections.java ++++ b/src/java.base/share/classes/java/util/Collections.java +@@ -816,15 +816,16 @@ public class Collections { + if (distance == 0) + return; + +- for (int cycleStart = 0, nMoved = 0; nMoved != size; cycleStart++) { ++ int bound = size - distance; ++ for (int cycleStart = 0, nMoved = 0; nMoved < size; cycleStart++) { + T displaced = list.get(cycleStart); + int i = cycleStart; + do { +- i += distance; +- if (i >= size) ++ if (i >= bound) + i -= size; ++ i += distance; + displaced = list.set(i, displaced); +- nMoved ++; ++ nMoved++; + } while (i != cycleStart); + } + } +diff --git a/test/jdk/java/util/Collections/RotateHuge.java b/test/jdk/java/util/Collections/RotateHuge.java +new file mode 100644 +index 000000000..44368aff2 +--- /dev/null ++++ b/test/jdk/java/util/Collections/RotateHuge.java +@@ -0,0 +1,83 @@ ++/* ++ * Copyright (c) 2023, 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 8314236 ++ * @summary Overflow in Collections.rotate ++ */ ++ ++import java.util.AbstractList; ++import java.util.Collections; ++import java.util.List; ++import java.util.Objects; ++import java.util.RandomAccess; ++ ++public class RotateHuge { ++ ++ private static final class MockList extends AbstractList ++ implements RandomAccess { ++ private final int size; ++ ++ public MockList(final int size) { ++ if (size < 0) ++ throw new IllegalArgumentException("Illegal size: " + size); ++ this.size = size; ++ } ++ ++ @Override ++ public Object get(final int index) { ++ Objects.checkIndex(index, size); ++ return null; ++ } ++ ++ @Override ++ public Object set(final int index, final Object element) { ++ Objects.checkIndex(index, size); ++ return null; ++ } ++ ++ @Override ++ public int size() { ++ return size; ++ } ++ } ++ ++ public static void main(final String[] args) { ++ testRotate((1 << 30) + 1, -(1 << 30) - 2); ++ testRotate((1 << 30) + 1, 1 << 30); ++ testRotate(Integer.MAX_VALUE, Integer.MIN_VALUE); ++ testRotate(Integer.MAX_VALUE, Integer.MIN_VALUE + 3); ++ testRotate(Integer.MAX_VALUE, 2); ++ testRotate(Integer.MAX_VALUE, Integer.MAX_VALUE - 1); ++ } ++ ++ /* ++ * This test covers only index computations. ++ * Correctness of elements rotation is not checked. ++ */ ++ private static void testRotate(final int size, final int distance) { ++ final List list = new MockList(size); ++ Collections.rotate(list, distance); ++ } ++} +-- +2.48.1 + diff --git a/Backport-JDK-8340532-C2-assert-is_OuterStripMinedLoo.patch b/Backport-JDK-8340532-C2-assert-is_OuterStripMinedLoo.patch new file mode 100644 index 0000000000000000000000000000000000000000..3892e5426b121b7bda33f59e537f51686a855d8a --- /dev/null +++ b/Backport-JDK-8340532-C2-assert-is_OuterStripMinedLoo.patch @@ -0,0 +1,116 @@ +Subject: [PATCH] Backport JDK-8340532: C2: assert(is_OuterStripMinedLoop()) + failed: invalid node class: IfTrue + +--- + src/hotspot/share/opto/ifnode.cpp | 8 +++ + src/hotspot/share/opto/loopTransform.cpp | 1 - + .../TestIdenticalDominatingCLE.java | 66 +++++++++++++++++++ + 3 files changed, 74 insertions(+), 1 deletion(-) + create mode 100644 test/hotspot/jtreg/compiler/loopstripmining/TestIdenticalDominatingCLE.java + +diff --git a/src/hotspot/share/opto/ifnode.cpp b/src/hotspot/share/opto/ifnode.cpp +index f63f4ae80..f0e1b154d 100644 +--- a/src/hotspot/share/opto/ifnode.cpp ++++ b/src/hotspot/share/opto/ifnode.cpp +@@ -1494,6 +1494,14 @@ Node* IfNode::Ideal(PhaseGVN *phase, bool can_reshape) { + Node* prev_dom = search_identical(dist); + + if (prev_dom != nullptr) { ++ // Dominating CountedLoopEnd (left over from some now dead loop) will become the new loop exit. Outer strip mined ++ // loop will go away. Mark this loop as no longer strip mined. ++ if (is_CountedLoopEnd()) { ++ CountedLoopNode* counted_loop_node = as_CountedLoopEnd()->loopnode(); ++ if (counted_loop_node != nullptr) { ++ counted_loop_node->clear_strip_mined(); ++ } ++ } + // Replace dominated IfNode + return dominated_by(prev_dom, igvn, false); + } +diff --git a/src/hotspot/share/opto/loopTransform.cpp b/src/hotspot/share/opto/loopTransform.cpp +index e35657cd1..bb9a54919 100644 +--- a/src/hotspot/share/opto/loopTransform.cpp ++++ b/src/hotspot/share/opto/loopTransform.cpp +@@ -717,7 +717,6 @@ void PhaseIdealLoop::do_peeling(IdealLoopTree *loop, Node_List &old_new) { + #endif + } + } +- Node* entry = head->in(LoopNode::EntryControl); + + // Step 1: Clone the loop body. The clone becomes the peeled iteration. + // The pre-loop illegally has 2 control users (old & new loops). +diff --git a/test/hotspot/jtreg/compiler/loopstripmining/TestIdenticalDominatingCLE.java b/test/hotspot/jtreg/compiler/loopstripmining/TestIdenticalDominatingCLE.java +new file mode 100644 +index 000000000..371c0fb2b +--- /dev/null ++++ b/test/hotspot/jtreg/compiler/loopstripmining/TestIdenticalDominatingCLE.java +@@ -0,0 +1,66 @@ ++/* ++ * Copyright (c) 2024, Red Hat, Inc. 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 8340532 ++ * @summary C2: assert(is_OuterStripMinedLoop()) failed: invalid node class: IfTrue ++ * @requires vm.compiler2.enabled ++ * @run main/othervm -XX:CompileOnly=TestIdenticalDominatingCLE::* -XX:CompileThreshold=100 -Xcomp -XX:-TieredCompilation ++ * -XX:-RangeCheckElimination -XX:LoopMaxUnroll=0 TestIdenticalDominatingCLE ++ * ++ */ ++ ++ ++public class TestIdenticalDominatingCLE { ++ boolean bFld; ++ long lFld; ++ float[][] fArr = new float[6][6]; ++ ++ public static void main(String[] var0) { ++ TestIdenticalDominatingCLE t = new TestIdenticalDominatingCLE(); ++ t.test(); ++ } ++ ++ void test() { ++ int i = 0; ++ do { ++ for (int j = 0; j < 2; j++) { ++ float f = fArr[j][3] / Float.valueOf((float)1.318095814E9); ++ switch (i) { ++ case 1: ++ if (bFld ^ bFld) { ++ } else { ++ for (int k = 0; k < 600; k++) { ++ } ++ } ++ break; ++ default: ++ if (bFld) { ++ } ++ } ++ } ++ lFld = ++i; ++ } while (i < 6); ++ } ++} +-- +2.48.1 + diff --git a/huawei-fix-arm32-build-fail-undefined-reference-_Copy_conjo.patch b/huawei-fix-arm32-build-fail-undefined-reference-_Copy_conjo.patch new file mode 100644 index 0000000000000000000000000000000000000000..8c1c5ed416092d066f043d1f9b4d3851675c4a21 --- /dev/null +++ b/huawei-fix-arm32-build-fail-undefined-reference-_Copy_conjo.patch @@ -0,0 +1,23 @@ +Subject: [PATCH] fix arm32 build fail: undefined reference + _Copy_conjoint_bytes + +--- + src/hotspot/os_cpu/linux_arm/linux_arm_32.S | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/src/hotspot/os_cpu/linux_arm/linux_arm_32.S b/src/hotspot/os_cpu/linux_arm/linux_arm_32.S +index aa839a1e3..cfac173b1 100644 +--- a/src/hotspot/os_cpu/linux_arm/linux_arm_32.S ++++ b/src/hotspot/os_cpu/linux_arm/linux_arm_32.S +@@ -28,8 +28,6 @@ + # point or use it in the same manner as does the server + # compiler. + +- .globl _Copy_conjoint_bytes +- .type _Copy_conjoint_bytes, %function + .globl _Copy_arrayof_conjoint_bytes + .type _Copy_arrayof_conjoint_bytes, %function + .globl _Copy_disjoint_words +-- +2.34.1 + diff --git a/openjdk-21.spec b/openjdk-21.spec index 98ce7a842ed6c066f8b52bdd9e7204be6d5916f4..e097bcc3656b832161db87d211eb67ae7eaf744a 100644 --- a/openjdk-21.spec +++ b/openjdk-21.spec @@ -905,7 +905,7 @@ Name: java-21-%{origin} Version: %{newjavaver}.%{buildver} # This package needs `.rolling` as part of Release so as to not conflict on install with # java-X-openjdk. I.e. when latest rolling release is also an LTS release packaged as -Release: 5 +Release: 6 # 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 @@ -1037,6 +1037,10 @@ Patch85: huawei-Adapt-to-clang-build-toolchain.patch Patch87: huawei-fix-build-fail-realpath.patch Patch88: 8352716-tz-Update-Timezone-Data-to-2025b.patch Patch89: heapdump-bug-fix.patch +Patch90: Backport-JDK-7036144-GZIPInputStream-readTrailer-use.patch +Patch91: Backport-JDK-8314236-Overflow-in-Collections.rotate.patch +Patch92: Backport-JDK-8340532-C2-assert-is_OuterStripMinedLoo.patch +Patch93: huawei-fix-arm32-build-fail-undefined-reference-_Copy_conjo.patch ############################################ # # LoongArch64 specific patches @@ -1340,6 +1344,10 @@ pushd %{top_level_dir_name} %patch87 -p1 %patch88 -p1 %patch89 -p1 +%patch90 -p1 +%patch91 -p1 +%patch92 -p1 +%patch93 -p1 popd # openjdk %endif @@ -1915,6 +1923,12 @@ cjc.mainProgram(args) -- the returns from copy_jdk_configs.lua should not affect %changelog +* Thu Jul 10 2025 Benshuai5D - 1:21.0.7.6-6 +- add Backport-JDK-7036144-GZIPInputStream-readTrailer-use.patch +- add Backport-JDK-8314236-Overflow-in-Collections.rotate.patch +- add Backport-JDK-8340532-C2-assert-is_OuterStripMinedLoo.patch +- add huawei-fix-arm32-build-fail-undefined-reference-_Copy_conjo.patch + * Sat May 17 2025 Benshuai5D - 1:21.0.7.6-5 - add heapdump-bug-fix.patch