JDK-8237643 : VM initialization fails with -XX:+UseNUMA if only one processor is available (_SC_NPROCESSORS_ONLN = 1)
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 8,11,12,13,14,15
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: linux
  • Submitted: 2020-01-22
  • Updated: 2020-06-03
  • Resolved: 2020-06-03
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.
JDK 15
15Resolved
Related Reports
Relates :  
Description
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (open/src/hotspot/share/utilities/growableArray.hpp:286), pid=4187, tid=4188
#  assert(0 <= i && i < _len) failed: illegal index
#
# JRE version:  (15.0) (slowdebug build )
# Java VM: Java HotSpot(TM) 64-Bit Server VM (slowdebug 15-internal+0-2019-11-08-0757471.christian..., mixed mode, sharing, tiered, compressed oops, serial gc, linux-amd64)
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P" (or dumping to /home/christian/jdk/core.4187)
#
#

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

Command Line: -XX:+UseNUMA 

Host: work, Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz, 1 cores, 15G, Ubuntu 18.04.3 LTS
Time: Wed Jan 22 13:50:21 2020 CET elapsed time: 0 seconds (0d 0h 0m 0s)

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

Current thread is native thread

Stack: [0x00007fd428d90000,0x00007fd428e91000],  sp=0x00007fd428e8f5a0,  free space=1021k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x10fa80f]  VMError::report_and_die(int, char const*, char const*, __va_list_tag*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long)+0x80f
V  [libjvm.so+0x10f9f9d]  VMError::report_and_die(Thread*, void*, char const*, int, char const*, char const*, __va_list_tag*)+0x57
V  [libjvm.so+0x723323]  report_vm_error(char const*, int, char const*, char const*, ...)+0x205
V  [libjvm.so+0x50f3c2]  GrowableArray<int>::at_put(int, int const&)+0x56
V  [libjvm.so+0xe9134b]  os::Linux::rebuild_cpu_to_node_map()+0x311
V  [libjvm.so+0xe90f9f]  os::Linux::libnuma_init()+0x29f
V  [libjvm.so+0xe9596f]  os::Linux::numa_init()+0x1f
V  [libjvm.so+0xe95c8e]  os::init_2()+0x100
V  [libjvm.so+0x107b1cb]  Threads::create_vm(JavaVMInitArgs*, bool*)+0x179
V  [libjvm.so+0xa952d4]  JNI_CreateJavaVM_inner(JavaVM_**, void**, void*)+0xda
V  [libjvm.so+0xa955ce]  JNI_CreateJavaVM+0x32
C  [libjli.so+0x7604]  InitializeJVM+0x13a
C  [libjli.so+0x41f8]  JavaMain+0xc6
C  [libjli.so+0xbc45]  ThreadJavaMain+0x27

CPU:total 1 (initial active 1) 


Can easily be verified by using rr [1] which sets _SC_NPROCESSORS_ONLN and _SC_NPROCESSORS_CONF to 1 [2]:
    rr java -XX:+UseNUMA --version

Also fails with:
    rr java -XX:+UnlockExperimentalVMOptions -XX:+UseZGC --version


The _cpu_to_node GrowableArray has length 1 since the processor count is 1 (set at [3]). It then crashes at [4] because the index is 0*BitsPerCLong + 1 = 1 but the array has only length 1.


[1] https://rr-project.org/
[2] https://github.com/mozilla/rr/blob/master/src/preload/overrides.c#L84
[3] http://hg.openjdk.java.net/jdk/jdk/file/ec9dead6ae87/src/hotspot/os/linux/os_linux.cpp#l3222
[4] http://hg.openjdk.java.net/jdk/jdk/file/ec9dead6ae87/src/hotspot/os/linux/os_linux.cpp#l3268
Comments
This seems to be a bug of RR where it intercepts sysconf(_SC_NPROCESSORS_CONF) and returns 1 (processor), but does not intercept libnuma calls which returns actual NUMA node count. This inconsistency causes the crash. Workaround: -XX:-UseNUMA -XX:ActiveProcessorCount=<n>
03-06-2020

Also affected when only using -XX:+UseZGC or -XX:+UseShenandoahGC which enable UseNUMA.
03-02-2020