JDK-8247522 : assert(is_aligned(class_space_rs.base(), class_space_alignment)) failed: Sanity
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-06-13
  • Updated: 2024-10-17
  • Resolved: 2020-06-15
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 JDK 16
15 b28Fixed 16Fixed
Related Reports
Relates :  
Relates :  
Description
The following assert was observed in our CI/CD which can be reproduced by runtime/cds/appcds/SharedBaseAddress.java and runtime/cds/SharedBaseAddress.java
---------------------------------------------------------
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/data/workspace/jdk15/src/hotspot/share/memory/metaspaceShared.cpp:2543), pid=27502, tid=27505
#  assert(is_aligned(class_space_rs.base(), class_space_alignment)) failed: Sanity
#
# JRE version:  (15.0) (fastdebug build )
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 15-internal+0-adhoc.root.jdk15, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x118ad04]  MetaspaceShared::reserve_address_space_for_archives(FileMapInfo*, FileMapInfo*, bool, ReservedSpace&, ReservedSpace&)+0x564
---------------------------------------------------------


```
Stack: [0x00007fea99408000,0x00007fea99509000],  sp=0x00007fea99507750,  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+0x118ad04]  MetaspaceShared::reserve_address_space_for_archives(FileMapInfo*, FileMapInfo*, bool, ReservedSpace&, ReservedSpace&)+0x564
V  [libjvm.so+0x118d86f]  MetaspaceShared::map_archives(FileMapInfo*, FileMapInfo*, bool)+0xcf
V  [libjvm.so+0x118de53]  MetaspaceShared::initialize_runtime_shared_and_meta_spaces()+0xc3
V  [libjvm.so+0x11842fd]  Metaspace::global_initialize()+0x42d
V  [libjvm.so+0x16bf6fa]  universe_init()+0xca
V  [libjvm.so+0xc1ccce]  init_globals()+0x5e
V  [libjvm.so+0x167ddc7]  Threads::create_vm(JavaVMInitArgs*, bool*)+0x287
V  [libjvm.so+0xd9a7a9]  JNI_CreateJavaVM+0x99
C  [libjli.so+0x415a]  JavaMain+0x8a
C  [libjli.so+0x7a39]  ThreadJavaMain+0x9
```

It might be fixed by:
```
diff -r 1c81917f228b src/hotspot/share/memory/metaspaceShared.cpp
--- a/src/hotspot/share/memory/metaspaceShared.cpp      Fri Jun 12 14:33:20 2020 -0700
+++ b/src/hotspot/share/memory/metaspaceShared.cpp      Sat Jun 13 16:51:46 2020 +0800
@@ -2502,8 +2502,8 @@
          "CompressedClassSpaceSize malformed: "
          SIZE_FORMAT, CompressedClassSpaceSize);

-  const size_t ccs_begin_offset = align_up(archive_space_size,
-                                           class_space_alignment);
+  const size_t ccs_begin_offset = align_up((size_t)base_address + archive_space_size,
+                                           class_space_alignment) - (size_t)base_address;
   const size_t gap_size = ccs_begin_offset - archive_space_size;

   const size_t total_range_size =
```
Comments
Changeset: ca85c5ab Author: Jie Fu <jiefu@tencent.com> Committer: Jie Fu <jiefu@openjdk.org> Date: 2020-06-13 23:10:26 +0000 URL: https://git.openjdk.java.net/lanai/commit/ca85c5ab
02-07-2020

Changeset: ca85c5ab Author: Jie Fu <jiefu@tencent.com> Committer: Jie Fu <jiefu@openjdk.org> Date: 2020-06-13 23:10:26 +0000 URL: https://git.openjdk.java.net/panama-foreign/commit/ca85c5ab
02-07-2020

Changeset: ca85c5ab Author: Jie Fu <jiefu@tencent.com> Committer: Jie Fu <jiefu@openjdk.org> Date: 2020-06-13 23:10:26 +0000 URL: https://git.openjdk.java.net/amber/commit/ca85c5ab
02-07-2020

URL: https://hg.openjdk.java.net/jdk/jdk15/rev/dba78a53ca7d User: jiefu Date: 2020-06-15 12:49:56 +0000
15-06-2020

RFR: https://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2020-June/040159.html
13-06-2020

The problem occurs when - SharedBaseAddress is not aligned to metaspace alignment - which atm is 16K but will be 4M in the future - we actually managed to reserve address space at that location.
13-06-2020