JDK-8315739 : Missing null check in os::vm_min_address
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 22
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • Submitted: 2023-09-06
  • Updated: 2023-09-25
  • Resolved: 2023-09-21
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 22
22 masterFixed
Related Reports
Relates :  
Description
Happens when building a Linux JDK on WSL1:

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f790aad3a94, pid=6304, tid=6328

Stack: [0x00007f7908540000,0x00007f7908641000],  sp=0x00007f790863ef50,  free space=1019k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libc.so.6+0x63a94]
C  [libc.so.6+0x6323d]  __isoc99_fscanf+0x9d
V  [libjvm.so+0x1507085]  os::attempt_reserve_memory_between(char*, char*, unsigned long, unsigned long, bool)+0x115  (os.cpp:1887)
V  [libjvm.so+0x13f7c9b]  Metaspace::reserve_address_space_for_compressed_classes(unsigned long, bool)+0x6b  (metaspace.cpp:596)
V  [libjvm.so+0x13f87e4]  Metaspace::global_initialize()+0x834  (metaspace.cpp:796)
V  [libjvm.so+0x198b904]  universe_init()+0xf4  (universe.cpp:796)
V  [libjvm.so+0xe5d74b]  init_globals()+0x3b  (init.cpp:124)
V  [libjvm.so+0x19554e5]  Threads::create_vm(JavaVMInitArgs*, bool*)+0x2c5  (threads.cpp:550)
V  [libjvm.so+0xfd5918]  JNI_CreateJavaVM+0x58  (jni.cpp:3576)
C  [libjli.so+0x4701]  JavaMain+0xa1  (java.c:1522)
C  [libjli.so+0x82bd]  ThreadJavaMain+0xd  (java_md.c:650)

See https://github.com/openjdk/jdk/blob/5cbff2460812fee707f9d96ab00a628d1ce3fbef/src/hotspot/os/linux/os_linux.cpp#L4256

The file /proc/sys/vm/mmap_min_addr/proc/sys/vm/mmap_min_addr does not exist on WSL.
Comments
Changeset: 349723cb Author: Daniel JeliƄski <djelinski@openjdk.org> Date: 2023-09-21 12:43:53 +0000 URL: https://git.openjdk.org/jdk/commit/349723cb8dd7a5e496f348dc8689431480ef1083
21-09-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/15596 Date: 2023-09-06 15:29:30 +0000
06-09-2023

WSL Kernel seems to be in a sorry state. `/proc/sys/vm/mmap_min_addr` is part of the non-optional proc fs since Linux 2.6.29. I'm on vacation right now, but this should be trivial to fix: ''' diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 3a1785b27b5..f99cde5bc19 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -4254,7 +4254,7 @@ size_t os::vm_min_address() { if (value == 0) { assert(is_aligned(_vm_min_address_default, os::vm_allocation_granularity()), "Sanity"); FILE* f = fopen("/proc/sys/vm/mmap_min_addr", "r"); - if (fscanf(f, "%zu", &value) != 1) { + if (f != nullptr && fscanf(f, "%zu", &value) != 1) { value = _vm_min_address_default; } value = MAX2(_vm_min_address_default, value); ''' Cheers, Thomas
06-09-2023

[~stuefe] could you fix this?
06-09-2023