Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8311752 | 17.0.9 | Fei Yang | P4 | Resolved | Fixed | b01 |
1. Run foreign jtreg tests with fastdebug build on linux-riscv64 platform:
$ make run-test-only TEST="jdk_foreign" JTREG="TIMEOUT_FACTOR=24"
--------------------------------------------------
TEST: java/foreign/TestDowncallScope.java
TEST JDK: /home/fyang/openjdk-jdk/build/linux-riscv64-server-fastdebug/images/jdk
......
test TestDowncallScope.testDowncall(9928, "f16_P_PSS_DP", NON_VOID, [POINTER, STRUCT, STRUCT], [DOUBLE, POINTER]): success
test TestDowncallScope.testDowncall(9945, "f16_P_PSS_IPI", NON_VOID, [POINTER, STRUCT, STRUCT], [INT, POINTER, INT]): success
test TestDowncallScope.testDowncall(9962, "f16_P_PSS_FPF", NON_VOID, [POINTER, STRUCT, STRUCT], [FLOAT, POINTER, FLOAT]): success
test TestDowncallScope.testDowncall(9979, "f16_P_PSS_DPD", NON_VOID, [POINTER, STRUCT, STRUCT], [DOUBLE, POINTER, DOUBLE]): success
test TestDowncallScope.testDowncall(9996, "f16_P_PSS_PPP", NON_VOID, [POINTER, STRUCT, STRUCT], [POINTER, POINTER, POINTER]): success
test TestDowncallScope.testDowncall(10013, "f16_S_SII_PI", NON_VOID, [STRUCT, INT, INT], [POINTER, INT]): success
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (0xe0000000), pid=464665, tid=464685
# stop: must be a primitive array
#
# JRE version: OpenJDK Runtime Environment (21.0) (fastdebug build 21-internal-adhoc.fyang.openjdk-jdk)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 21-internal-adhoc.fyang.openjdk-jdk, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-riscv64)
# Problematic frame:
# v ~StubRoutines::generic_arraycopy 0x0000003fa3de0df4
#
# 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/fyang/openjdk-jdk/build/linux-riscv64-server-fastdebug/test-support/jtreg_test_jdk_jdk_foreign/scratch/0/core.464665)
#
# An error report file with more information is saved as:
# /home/fyang/openjdk-jdk/build/linux-riscv64-server-fastdebug/test-support/jtreg_test_jdk_jdk_foreign/scratch/0/hs_err_pid464665.log
[73.630s][warning][os] Loading hsdis library failed
#
# If you would like to submit a bug report, please visit:
# https://bugreport.java.com/bugreport/crash.jsp
#
......
--------------------------------------------------
2. Some initial analysis:
This problem only triggers when using debug build to run foreign jtreg tests.
JDK-8301818 made following code changes in function generate_generic_copy [1]:
```
// At this point, it is known to be a typeArray (array_tag 0x3).
#ifdef ASSERT
{
BLOCK_COMMENT("assert primitive array {");
Label L;
- __ mvw(t1, Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift);
+ __ mv(t1, Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift);
__ bge(lh, t1, L);
__ stop("must be a primitive array");
__ bind(L);
BLOCK_COMMENT("} assert primitive array done");
}
#endif
```
Notably, Klass::_lh_array_tag_type_value is of type unsigned int:
```
static const unsigned int _lh_array_tag_type_value = 0Xffffffff;
static const int _lh_array_tag_shift = BitsPerInt - _lh_array_tag_bits;
static const int _lh_array_tag_bits = 2;
```
So Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift would be 0xc0000000 of type unsigned int.
Previously, 'mvw' function would sign-extend this value into 64-bit 0xffffffffc0000000 since we want to do 64-bit signed compare and branch with 'bge' instruction next.
```
template<typename T, ENABLE_IF(std::is_integral<T>::value)>
inline void mv(Register Rd, T o) { li(Rd, (int64_t)o); }
inline void mvw(Register Rd, int32_t imm32) { mv(Rd, imm32); }
```
But this is not the case when changed to use 'mv' with type unsigned int. So I think this changes the behaviour.
Simple fix would be adding an explict int32_t type conversion for this value, like:
__ mv(t1, (int32_t)(Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift));
[1] https://github.com/openjdk/jdk/commit/c04a982eb47170f3c613617179fca012bb4d40ae
$ make run-test-only TEST="jdk_foreign" JTREG="TIMEOUT_FACTOR=24"
--------------------------------------------------
TEST: java/foreign/TestDowncallScope.java
TEST JDK: /home/fyang/openjdk-jdk/build/linux-riscv64-server-fastdebug/images/jdk
......
test TestDowncallScope.testDowncall(9928, "f16_P_PSS_DP", NON_VOID, [POINTER, STRUCT, STRUCT], [DOUBLE, POINTER]): success
test TestDowncallScope.testDowncall(9945, "f16_P_PSS_IPI", NON_VOID, [POINTER, STRUCT, STRUCT], [INT, POINTER, INT]): success
test TestDowncallScope.testDowncall(9962, "f16_P_PSS_FPF", NON_VOID, [POINTER, STRUCT, STRUCT], [FLOAT, POINTER, FLOAT]): success
test TestDowncallScope.testDowncall(9979, "f16_P_PSS_DPD", NON_VOID, [POINTER, STRUCT, STRUCT], [DOUBLE, POINTER, DOUBLE]): success
test TestDowncallScope.testDowncall(9996, "f16_P_PSS_PPP", NON_VOID, [POINTER, STRUCT, STRUCT], [POINTER, POINTER, POINTER]): success
test TestDowncallScope.testDowncall(10013, "f16_S_SII_PI", NON_VOID, [STRUCT, INT, INT], [POINTER, INT]): success
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (0xe0000000), pid=464665, tid=464685
# stop: must be a primitive array
#
# JRE version: OpenJDK Runtime Environment (21.0) (fastdebug build 21-internal-adhoc.fyang.openjdk-jdk)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 21-internal-adhoc.fyang.openjdk-jdk, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-riscv64)
# Problematic frame:
# v ~StubRoutines::generic_arraycopy 0x0000003fa3de0df4
#
# 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/fyang/openjdk-jdk/build/linux-riscv64-server-fastdebug/test-support/jtreg_test_jdk_jdk_foreign/scratch/0/core.464665)
#
# An error report file with more information is saved as:
# /home/fyang/openjdk-jdk/build/linux-riscv64-server-fastdebug/test-support/jtreg_test_jdk_jdk_foreign/scratch/0/hs_err_pid464665.log
[73.630s][warning][os] Loading hsdis library failed
#
# If you would like to submit a bug report, please visit:
# https://bugreport.java.com/bugreport/crash.jsp
#
......
--------------------------------------------------
2. Some initial analysis:
This problem only triggers when using debug build to run foreign jtreg tests.
```
// At this point, it is known to be a typeArray (array_tag 0x3).
#ifdef ASSERT
{
BLOCK_COMMENT("assert primitive array {");
Label L;
- __ mvw(t1, Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift);
+ __ mv(t1, Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift);
__ bge(lh, t1, L);
__ stop("must be a primitive array");
__ bind(L);
BLOCK_COMMENT("} assert primitive array done");
}
#endif
```
Notably, Klass::_lh_array_tag_type_value is of type unsigned int:
```
static const unsigned int _lh_array_tag_type_value = 0Xffffffff;
static const int _lh_array_tag_shift = BitsPerInt - _lh_array_tag_bits;
static const int _lh_array_tag_bits = 2;
```
So Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift would be 0xc0000000 of type unsigned int.
Previously, 'mvw' function would sign-extend this value into 64-bit 0xffffffffc0000000 since we want to do 64-bit signed compare and branch with 'bge' instruction next.
```
template<typename T, ENABLE_IF(std::is_integral<T>::value)>
inline void mv(Register Rd, T o) { li(Rd, (int64_t)o); }
inline void mvw(Register Rd, int32_t imm32) { mv(Rd, imm32); }
```
But this is not the case when changed to use 'mv' with type unsigned int. So I think this changes the behaviour.
Simple fix would be adding an explict int32_t type conversion for this value, like:
__ mv(t1, (int32_t)(Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift));
[1] https://github.com/openjdk/jdk/commit/c04a982eb47170f3c613617179fca012bb4d40ae
- backported by
-
JDK-8311752 RISC-V: Several foreign jtreg tests fail with debug build after JDK-8301818
- Resolved
- relates to
-
JDK-8301818 RISC-V: Factor out function mvw from MacroAssembler
- Resolved
- links to
-
Commit openjdk/jdk17u-dev/966fc82d
-
Commit openjdk/jdk/7c233bc1
-
Commit openjdk/riscv-port-jdk17u/d7d50c3b
-
Review openjdk/jdk17u-dev/1427
-
Review openjdk/jdk/12481
-
Review openjdk/riscv-port-jdk17u/62
(3 links to)