Skip to content

8387381: RISC-V: assert failed with fastdebug build on systems with different core types#31717

Open
zifeihan wants to merge 1 commit into
openjdk:masterfrom
zifeihan:JDK-8387381
Open

8387381: RISC-V: assert failed with fastdebug build on systems with different core types#31717
zifeihan wants to merge 1 commit into
openjdk:masterfrom
zifeihan:JDK-8387381

Conversation

@zifeihan

@zifeihan zifeihan commented Jun 29, 2026

Copy link
Copy Markdown
Member

HI, Can you help to review this patch? Thanks!
Here is a crash with a fastdebug build on SpacemiT Key Stone K3, which has different core types.

zifeihan@riscv-spacemitk3picoitx:~$ cat /proc/cpuinfo | grep -i march
marchid		: 0x8000000058000002
marchid		: 0x8000000058000002
marchid		: 0x8000000058000002
marchid		: 0x8000000058000002
marchid		: 0x8000000058000002
marchid		: 0x8000000058000002
marchid		: 0x8000000058000002
marchid		: 0x8000000058000002
marchid		: 0x8000000041000002
marchid		: 0x8000000041000002
marchid		: 0x8000000041000002
marchid		: 0x8000000041000002
marchid		: 0x8000000041000002
marchid		: 0x8000000041000002
marchid		: 0x8000000041000002
marchid		: 0x8000000041000002
zifeihan@riscv-spacemitk3picoitx:~$ cat /home/zifeihan/jdk/make/hs_err_pid1348135.log | head -100
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/home/zifeihan/jdk/src/hotspot/cpu/riscv/vm_version_riscv.hpp:206), pid=1348135, tid=1348139
#  assert(value != DEFAULT_VALUE) failed: Sanity
#
# JRE version:  (28.0) (fastdebug build )
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 28-internal-adhoc.zifeihan.jdk, mixed mode, tiered, compressed oops, compact obj headers, g1 gc, linux-riscv64)
# Problematic frame:
# V  [libjvm.so+0x14ce4cc]  RiscvHwprobe::add_features_from_query_result()+0x6fa
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
#

---------------  S U M M A R Y ------------

Command Line: -Denv.class.path= -Dapplication.home=/home/zifeihan/jdk/build/linux-riscv64-server-fastdebug/jdk --add-modules=ALL-DEFAULT -Xms8m -Djava.io.tmpdir=/home/zifeihan/jdk/build/linux-riscv64-server-fastdebug/support/javatmp -Djdk.module.main=jdk.compiler jdk.compiler/com.sun.tools.javac.Main -g -Xlint:all -source 28 -target 28 -implicit:none -Xprefer:source -XDignore.symbol.file=true --add-modules jdk.compiler,jdk.jdeps --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED -encoding utf-8 -Werror -Xlint:-options -XDmodifiedInputs=/home/zifeihan/jdk/build/linux-riscv64-server-fastdebug/buildtools/create_symbols_javac/_the.COMPILE_CREATE_SYMBOLS_batch.modfiles.fixed -d /home/zifeihan/jdk/build/linux-riscv64-server-fastdebug/buildtools/create_symbols_javac @/home/zifeihan/jdk/build/linux-riscv64-server-fastdebug/buildtools/create_symbols_javac/_the.COMPILE_CREATE_SYMBOLS_batch.filelist

Host: riscv-spacemitk3picoitx, RISCV64, 16 cores, 31G, Bianbu 4.0rc2
Time: Sun Jun 28 22:36:53 2026 CST elapsed time: 0.121988 seconds (0d 0h 0m 0s)

---------------  T H R E A D  ---------------

Current thread (0x0000003f9402df50):  JavaThread "Unknown thread" [_thread_in_vm, id=1348139, stack(0x0000003f9ac00000,0x0000003f9ae00000) (2048K)]

Stack: [0x0000003f9ac00000,0x0000003f9ae00000],  sp=0x0000003f9adfba70,  free space=2030k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x14ce4cc]  RiscvHwprobe::add_features_from_query_result()+0x6fa  (vm_version_riscv.hpp:206)
V  [libjvm.so+0x14ce53a]  RiscvHwprobe::probe_features()+0x64
V  [libjvm.so+0x194ad48]  VM_Version::setup_cpu_available_features()+0x48
V  [libjvm.so+0x194d572]  VM_Version::common_initialize()+0x56
V  [libjvm.so+0x194dabc]  VM_Version::initialize()+0xc
V  [libjvm.so+0x19495d8]  VM_Version_init()+0x28
V  [libjvm.so+0xd7c4c6]  init_globals()+0x62
V  [libjvm.so+0x184f11a]  Threads::create_vm(JavaVMInitArgs*, bool*)+0x35a
V  [libjvm.so+0xf4a174]  JNI_CreateJavaVM+0x64
C  [libjli.so+0x3aaa]  JavaMain+0x7c  (java.c:1494)
C  [libjli.so+0x76ca]  ThreadJavaMain+0xc  (java_md.c:646)
C  [libc.so.6+0x7799e]

On systems with different core types, the kernel hwprobe syscall returns (uint64_t)-1 as value for MARCHID/MIMPID when CPUs disagree[1]. RVNonExtFeatureValue uses the same -1 as its internal sentinel (DEFAULT_VALUE), so enable_feature(-1) hits the assert.

SpacemiT Key Stone K3 has X100 (marchid=0x8000000058000002) and A100 (marchid=0x8000000041000002) cores, querying all CPUs gives marchid=-1 and mimpid=-1.
Fix: use a separate bool _enabled flag instead of the sentinel value.
[1] https://docs.kernel.org/arch/riscv/hwprobe.html

For value-like keys (eg. vendor, arch, impl), the returned value will only be valid if all CPUs in the given set have the same value. Otherwise -1 will be returned. 

Testing

  • fastdebug build on SpacemiT Key Stone K3


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8387381: RISC-V: assert failed with fastdebug build on systems with different core types (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/31717/head:pull/31717
$ git checkout pull/31717

Update a local copy of the PR:
$ git checkout pull/31717
$ git pull https://git.openjdk.org/jdk.git pull/31717/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 31717

View PR using the GUI difftool:
$ git pr show -t 31717

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/31717.diff

Using Webrev

Link to Webrev Comment

@zifeihan zifeihan changed the title 8387381: RISC-V: assert "value != DEFAULT_VALUE" crash with fastdebug build on systems with different core types 8387381: RISC-V: assert failed with fastdebug build on systems with different core types Jun 29, 2026
@bridgekeeper

bridgekeeper Bot commented Jun 29, 2026

Copy link
Copy Markdown

👋 Welcome back gcao! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk

openjdk Bot commented Jun 29, 2026

Copy link
Copy Markdown

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Jun 29, 2026
@openjdk

openjdk Bot commented Jun 29, 2026

Copy link
Copy Markdown

@zifeihan The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk

openjdk Bot commented Jun 29, 2026

Copy link
Copy Markdown

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot-runtime. This can be overridden with the /reviewers command.

@openjdk openjdk Bot added the rfr Pull request is ready for review label Jun 29, 2026
@mlbridge

mlbridge Bot commented Jun 29, 2026

Copy link
Copy Markdown

Webrevs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-runtime hotspot-runtime-dev@openjdk.org rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

1 participant