RFR: 8337958: Out-of-bounds array access in secondary_super_cache

Gui Cao gcao at openjdk.org
Wed Aug 7 08:53:31 UTC 2024


On Tue, 6 Aug 2024 23:35:55 GMT, Andrew Haley <aph at openjdk.org> wrote:

> The fix for [JDK-8180450](https://bugs.openjdk.org/browse/JDK-8180450), secondary_super_cache does not scale well, has a rare (and benign) out-of-bounds array access. While this bug is very unlikely ever to cause a failure, it should be fixed.

@theRealAph Hi, I have prepared a small change for riscv platform. Can we take a ride? Thanks.
``` diff
diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
index e349eab3177..8bda4006992 100644
--- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
+++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
@@ -3973,8 +3973,8 @@ void MacroAssembler::lookup_secondary_supers_table_slow_path(Register r_super_kl

   // Check if bitmap is SECONDARY_SUPERS_BITMAP_FULL
   assert(Klass::SECONDARY_SUPERS_BITMAP_FULL == ~uintx(0), "Adjust this code");
-  addi(t0, r_bitmap, (u1)1);
-  beqz(t0, L_bitmap_full);
+  subw(t0, r_array_length, (u1)(Klass::SECONDARY_SUPERS_TABLE_SIZE - 2));
+  bgtz(t0, L_bitmap_full);

   // NB! Our caller has checked bits 0 and 1 in the bitmap. The
   // current slot (at secondary_supers[r_array_index]) has not yet

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

PR Comment: https://git.openjdk.org/jdk/pull/20483#issuecomment-2272957393


More information about the hotspot-dev mailing list