axiangyushanhaijing / powerpoint

https://wiki.openjdk.java.net/display/jdk8u
GNU General Public License v2.0
6 stars 3 forks source link

java -version 调试总结 #90

Open axiangyushanhaijing opened 2 years ago

axiangyushanhaijing commented 2 years ago

在合入 #pr87之后,make已经成功,执行java -version报错:

zhangxiang@k9-plct:~/rv-jdk8u/jdk8u$ java-version 
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000004001ccb0d0, pid=2459914, tid=0x00000040021c51e0
#
# JRE version:  (8.0_342) (build )
# Java VM: OpenJDK 64-Bit  VM (25.342-b00 interpreted mode linux-riscv64 compressed oops)
# Problematic frame:
# V  [libjvm.so+0x35e0d0]  MacroAssembler::load_mirror(RegisterImpl*, RegisterImpl*, RegisterImpl*)+0x124
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/zhangxiang/rv-jdk8u/jdk8u/hs_err_pid2459914.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
axiangyushanhaijing commented 1 year ago

经过代码阅读发现,由于rv64的源代码是基于jdk11的进行编写的,其中部分公共代码jdk8是没有的,主要涉及的是 **BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler()**,包括涉及到类BarrierSet的成员函数以及调用它的函数,于是参考aarch64的修改方法。对所有涉及到的地方逐一进行修改 当前分支 0910_fix_resolve_jobject_02 -- #101

并打上patch:

diff --git a/hotspot/src/cpu/riscv64/vm/assembler_riscv64.hpp b/hotspot/src/cpu/riscv64/vm/assembler_riscv64.hpp
index d019c50183..901d72b81e 100644
--- a/hotspot/src/cpu/riscv64/vm/assembler_riscv64.hpp
+++ b/hotspot/src/cpu/riscv64/vm/assembler_riscv64.hpp
@@ -247,12 +247,12 @@ class Address {
       _rspec(rspec),
       _target(target)  { }
   Address(Register r, Register r1, extend ext = lsl())
-    : _mode(base_plus_offset_reg), _base(r), _index(r1),
+    : _mode(base_plus_offset), _base(r), _index(r1),
     _ext(ext), _offset(0), _target(0) { }
   Address(Pre p)
-    : _mode(pre), _base(p.reg()), _offset(p.offset()) { }
+    : _mode(base_plus_offset), _base(p.reg()), _offset(p.offset()) { }
   Address(Post p)
-    : _mode(post), _base(p.reg()), _offset(p.offset()), _target(0) { }
+    : _mode(base_plus_offset), _base(p.reg()), _offset(p.offset()), _target(0) { }
   Address(address target, relocInfo::relocType rtype = relocInfo::external_word_type);

   const Register base() const {
diff --git a/hotspot/src/cpu/riscv64/vm/interp_masm_riscv64.cpp b/hotspot/src/cpu/riscv64/vm/interp_masm_riscv64.cpp
index 99abcb4b15..5526202868 100644
--- a/hotspot/src/cpu/riscv64/vm/interp_masm_riscv64.cpp
+++ b/hotspot/src/cpu/riscv64/vm/interp_masm_riscv64.cpp
@@ -278,7 +278,7 @@ void InterpreterMacroAssembler::load_resolved_reference_at_index(

   get_constant_pool(result);
   // load pointer for resolved_references[] objArray
-  ld(result, Address(result, ConstantPool::cache_offset_in_bytes()));
+ // ld(result, Address(result, ConstantPool::cache_offset_in_bytes()));
   ld(result, Address(result, ConstantPool::resolved_references_offset_in_bytes()));
   //resolve_oop_handle(result, tmp);
   // Add in the index
axiangyushanhaijing commented 1 year ago

10.25更新,基于当前分支 Fix _mode() in assembler_riscv64.hpp 当前报错

zhangxiang@k9-plct:~/rv-jdk8u/jdk8u/build/linux-riscv64-normal-core-slowdebug/jdk/bin$ qemu64 ./java -XX:+TraceBytecodes -version

[2369093] static void java.lang.Object.<clinit>()
[2369093]        1     0  invokestatic 16 <java/lang/Object.registerNatives()V> 

[2369093] static void java.lang.Throwable.<clinit>()
[2369093]        2     0  ldc <unresolved klass at 42>
[2369093]        3     2  invokevirtual 101 <java/lang/Class.desiredAssertionStatus()Z> 
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x000000400a8ad510, pid=2369091, tid=0x00000040027551e0
#
# JRE version:  (8.0_352) (build )
# Java VM: OpenJDK 64-Bit  VM (25.352-b00-debug interpreted mode linux-riscv64 compressed oops)
# Problematic frame:
# j  java.lang.Throwable.<clinit>()V+2
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/zhangxiang/rv-jdk8u/jdk8u/build/linux-riscv64-normal-core-slowdebug/jdk/bin/hs_err_pid2369091.log
#
# If you would like to submit a bug report, please visit:
axiangyushanhaijing commented 1 year ago

当前分支 0910_fix_resolve_jobject_02 --- diff

当前报错

zhangxiang@k9-plct:~/rv-jdk8u/jdk8u/build/linux-riscv64-normal-core-slowdebug$ cd jdk/bin/
zhangxiang@k9-plct:~/rv-jdk8u/jdk8u/build/linux-riscv64-normal-core-slowdebug/jdk/bin$ java-version 
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc:  SuppressErrorAt=/assembler_riscv64.hpp:759
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/home/zhangxiang/rv-jdk8u/jdk8u/hotspot/src/cpu/riscv64/vm/assembler_riscv64.hpp:759), pid=3810071, tid=0x00000040027551e0
#  Error: ShouldNotReachHere()
#
# JRE version:  (8.0_352) (build )
# Java VM: OpenJDK 64-Bit  VM (25.352-b00-debug interpreted mode linux-riscv64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/zhangxiang/rv-jdk8u/jdk8u/build/linux-riscv64-normal-core-slowdebug/jdk/bin/hs_err_pid3810071.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#
Current thread is 274919150048
Dumping core ...
Aborted
axiangyushanhaijing commented 1 year ago

/usr/bin/find: ‘/home/zhangxiang/rv-jdk8u/jdk8u/build/linux-riscv64-normal-core-slowdebug/hotspot/dist/lib’: No such file or directory

axiangyushanhaijing commented 1 year ago

gdb调试 hotspot/src/cpu/riscv64/vm/templateTable_riscv64.cpp 中的 aastore时发现,当定位到 do_oop_store_rv时,单步S无法进入该函数。