JDK-8328404 : RISC-V: Fix potential crash in C2_MacroAssembler::arrays_equals
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 23
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: riscv
  • Submitted: 2024-03-19
  • Updated: 2024-03-28
  • Resolved: 2024-03-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 23
23 b16Fixed
Description
Hi, The current behavior of C2_MacroAssembler::arrays_equals always load longword before comparison.
When array[0] is aligned to 32-bit (especially after JDK-8139457 which tries to relax alignment
of array elements), the last longword load will exceed the array limit and may touch the next
word beyond object layout in heap memory. So this should bear a similar problem as JDK-8328138.

Proposed fix changes this behavior and aligns with handling in C2_MacroAssembler::string_equals,
which will check the number of remaining array elements before loading the next longword.
No obvious changes witnessed from the JMH numbers or benchmarks like SPECjbb2015.

Patch also removed the AvoidUnalignedAccesses check in C2_MacroAssembler::string_equals as we
don't see extra performance gain when setting AvoidUnalignedAccesses to false when testing the
JMH tests or benchmarks like SPECjbb2015 on three popular RISC-V hardware platforms. We can
consider adding it back if it turns out to be usefull on future new hardwares.
Comments
Changeset: c7b9dc46 Author: Gui Cao <gcao@openjdk.org> Committer: Fei Yang <fyang@openjdk.org> Date: 2024-03-25 01:18:50 +0000 URL: https://git.openjdk.org/jdk/commit/c7b9dc463a7e0347fc2e2ce5578e8fb39ea0b733
25-03-2024

ILW = Potential crash on riscv, never observed, no known workaround = MLH = P4
20-03-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/18370 Date: 2024-03-19 03:44:10 +0000
19-03-2024