<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@DengXian";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:12.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:12.0pt;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-AU" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">Hi all,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I found that a non-zero build of jdk-20+16 crashes on Ubuntu 22.10 (kernel 5.19) running on QEMU.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The same build works on Ubuntu 22.04 (kernel 5.15) running on QEMU.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The error message is as follows.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"># To suppress the following error report, specify this argument<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"># after -XX: or in .hotspotrc:  SuppressErrorAt=/assembler_riscv.cpp:285<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"># A fatal error has been detected by the Java Runtime Environment:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#  Internal Error (/home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/assembler_riscv.cpp:285), pid=907, tid=908<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#  assert(is_unsigned_imm_in_range(imm64, 47, 0) || (imm64 == (int64_t)-1)) failed: bit 47 overflows in address constant<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"># JRE version:  (20.0) (slowdebug build )<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"># Java VM: OpenJDK 64-Bit Server VM (slowdebug 20-testing-builds.shipilev.net-openjdk-jdk-b212-20220922, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-riscv64)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"># Problematic frame:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"># V  [libjvm.so+0x39f41c]  Assembler::movptr_with_offset(Register, unsigned char*, int&)+0x96<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"># Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /home/ubuntu/core.907)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"># An error report file with more information is saved as:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"># /home/ubuntu/hs_err_pid907.log<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Here is the backtrace and local variables seen in gdb.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">(gdb) bt<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#0  0x00fffffff674941c in Assembler::movptr_with_offset (this=0xfffffff0000e30, Rd=...,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">    addr=0xfffffff71136b8 <SharedRuntime::exception_handler_for_return_address(JavaThread*, unsigned char*)> "9q\006\374\"\370", <incomplete sequence \364\200>, offset=@0xfffffff632f00c: 0)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">    at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/assembler_riscv.cpp:284<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#1  0x00fffffff6f17c5c in MacroAssembler::call_VM_leaf_base (this=0xfffffff0000e30,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">    entry_point=0xfffffff71136b8 <SharedRuntime::exception_handler_for_return_address(JavaThread*, unsigned char*)> "9q\006\374\"\370", <incomplete sequence \364\200>, number_of_arguments=2,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">    retaddr=0x0) at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp:568<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#2  0x00fffffff6f17da2 in MacroAssembler::call_VM_leaf (this=0xfffffff0000e30,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">    entry_point=0xfffffff71136b8 <SharedRuntime::exception_handler_for_return_address(JavaThread*, unsigned char*)> "9q\006\374\"\370", <incomplete sequence \364\200>, arg_0=..., arg_1=...)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">    at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp:588<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#3  0x00fffffff7222308 in StubGenerator::generate_forward_exception (this=0xfffffff632f1e8) at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp:546<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#4  0x00fffffff7231506 in StubGenerator::generate_initial (this=0xfffffff632f1e8) at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp:3870<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#5  0x00fffffff7231956 in StubGenerator::StubGenerator (this=0xfffffff632f1e8, code=0xfffffff632f3c8, phase=0)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">    at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp:3971<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#6  0x00fffffff721faa0 in StubGenerator_generate (code=0xfffffff632f3c8, phase=0) at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp:3988<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#7  0x00fffffff72322c8 in StubRoutines::initialize1 () at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/runtime/stubRoutines.cpp:228<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#8  0x00fffffff72330d2 in stubRoutines_init1 () at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/runtime/stubRoutines.cpp:389<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#9  0x00fffffff6c7823a in init_globals () at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/runtime/init.cpp:123<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#10 0x00fffffff72bcc34 in Threads::create_vm (args=0xfffffff632f7e0, canTryAgain=0xfffffff632f70b) at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/runtime/threads.cpp:570<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#11 0x00fffffff6d891ae in JNI_CreateJavaVM_inner (vm=0xfffffff632f838, penv=0xfffffff632f840, args=0xfffffff632f7e0)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">    at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/prims/jni.cpp:3628<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#12 0x00fffffff6d893a8 in JNI_CreateJavaVM (vm=0xfffffff632f838, penv=0xfffffff632f840, args=0xfffffff632f7e0) at /home/buildbot/worker/build-jdkX-debian10/build/src/hotspot/share/prims/jni.cpp:3714<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#13 0x00fffffff7fb1a44 in InitializeJVM (pvm=0xfffffff632f838, penv=0xfffffff632f840, ifn=0xfffffff632f890)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">    at /home/buildbot/worker/build-jdkX-debian10/build/src/java.base/share/native/libjli/java.c:1457<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#14 0x00fffffff7faef16 in JavaMain (_args=0xffffffffffc0d8) at /home/buildbot/worker/build-jdkX-debian10/build/src/java.base/share/native/libjli/java.c:413<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#15 0x00fffffff7fb50ea in ThreadJavaMain (args=0xffffffffffc0d8) at /home/buildbot/worker/build-jdkX-debian10/build/src/java.base/unix/native/libjli/java_md.c:650<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#16 0x00fffffff7ed7450 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">#17 0x00fffffff7f24ed2 in __thread_start () at ../sysdeps/unix/sysv/linux/riscv/clone.S:85<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">(gdb) info locals<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">imm64 = 0xfffffff71136b8<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">imm = 0xfffffff632efb0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">upper = 0xfffffff632efb0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">lower = 0xffffff80000000<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I suspect that the issue is due to the newer kernels (5.17+) supports sv48, and that increases the bits in the addresses that the assembler needs to handle. See kernel changelog
<a href="https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.17">https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.17</a>.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">To reproduce the issue, I use the following.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Guest Ubuntu 22.10: <a href="https://cdimage.ubuntu.com/ubuntu-server/daily-preinstalled/current/kinetic-preinstalled-server-riscv64+unmatched.img.xz">
https://cdimage.ubuntu.com/ubuntu-server/daily-preinstalled/current/kinetic-preinstalled-server-riscv64+unmatched.img.xz</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Guest Ubuntu 22.04: <a href="https://cdimage.ubuntu.com/releases/22.04.1/release/ubuntu-22.04.1-preinstalled-server-riscv64+unmatched.img.xz">
https://cdimage.ubuntu.com/releases/22.04.1/release/ubuntu-22.04.1-preinstalled-server-riscv64+unmatched.img.xz</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">JDK slowdebug build: <a href="https://builds.shipilev.net/openjdk-jdk/openjdk-jdk-linux-riscv64-server-slowdebug-gcc8-glibc2.28.tar.xz">
https://builds.shipilev.net/openjdk-jdk/openjdk-jdk-linux-riscv64-server-slowdebug-gcc8-glibc2.28.tar.xz</a> (OpenJDK 64-Bit Server VM (slowdebug build 20-testing-builds.shipilev.net-openjdk-jdk-b212-20220922, mixed mode))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">QEMU: installed via apt on Ubuntu 22.04 host<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">QEMU setup: <a href="https://wiki.ubuntu.com/RISC-V">
https://wiki.ubuntu.com/RISC-V</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Sincerely,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt">Zixian</span><o:p></o:p></p>
</div>
</body>
</html>