JDK-8327885 : runtime/Unsafe/InternalErrorTest.java enters endless loop on Alpine aarch64
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 23
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: linux_alpine
  • CPU: aarch64
  • Submitted: 2024-03-12
  • Updated: 2024-07-23
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.
Other
tbdUnresolved
Related Reports
Relates :  
Description
It's related to JDK-8322163 that replaced memset with a for loop on Alpine. JDK-8322163 fixed the test on Alpine x86_64 but it enters endless loop on Alpine aarch64.

The loop causes SIGBUS to be generated and the signal handler continues to the next instruction. As gcc generates strb with auto-increment on aarch64, the increment will be skipped.

Thread 2 "java" received signal SIGBUS, Bus error.
Copy::fill_to_memory_atomic (to=to@entry=0xffffdb004000, size=size@entry=999, value=value@entry=240 '\360') at src/hotspot/share/utilities/copy.cpp:252
252	      *(volatile jbyte*)(dst + off) = fill;
2: x/i $pc
=> 0xfffff6fefa40 <_ZN4Copy21fill_to_memory_atomicEPvmh+536>:	strb	w2, [x5], #1 

Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/18262 Date: 2024-03-13 07:34:11 +0000
13-03-2024

Seems that adjusting the loop for Alpine and making `off` volatile forces gcc to generate code with separate increment instruction diff --git a/src/hotspot/share/utilities/copy.cpp b/src/hotspot/share/utilities/copy.cpp index ed779796943..67b2d1f82e4 100644 --- a/src/hotspot/share/utilities/copy.cpp +++ b/src/hotspot/share/utilities/copy.cpp @@ -247,8 +247,10 @@ void Copy::fill_to_memory_atomic(void* to, size_t size, jubyte value) { // This code is used by Unsafe and may hit the next page after truncation of mapped memory. // Therefore, we use volatile to prevent compilers from replacing the loop by memset which // may not trigger SIGBUS as needed (observed on Alpine Linux x86_64) + // Also making counter volatile to prevent compilers from generating strb with auto-increment + // Otherwise, it may trigger endless loop on Alpine Linux aarch64 jbyte fill = value; - for (uintptr_t off = 0; off < size; off += sizeof(jbyte)) { + for (volatile uintptr_t off = 0; off < size; off += sizeof(jbyte)) { *(volatile jbyte*)(dst + off) = fill; } #else Thread 2 "java" received signal SIGBUS, Bus error. 0x0000fffff7000c3c in Copy::fill_to_memory_atomic (to=to@entry=0xffffdb00b000, size=size@entry=999, value=value@entry=240 '\360') at src/hotspot/share/utilities/copy.cpp:254 254 *(volatile jbyte*)(dst + off) = fill; 1: x/i $pc => 0xfffff7000c3c <_ZN4Copy21fill_to_memory_atomicEPvmh+476>: strb w2, [x0, x3]
12-03-2024