JDK-8267879 : ClassLoaderMetaspace destructor asserts on !_frozen
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 17
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2021-05-27
  • Updated: 2021-06-11
  • Resolved: 2021-06-02
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 17
17 b26Fixed
Related Reports
Relates :  
Description
The following test failed in the JDK17 CI:

runtime/cds/appcds/methodHandles/MethodHandlesAsCollectorTest.java

Here's a snippet from the log file:

[2.573s][info   ][cds       ] Regenerate MethodHandle Holder classes...done
[2.594s][info   ][cds       ] Rewriting and linking classes: done
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc:  SuppressErrorAt=/metaspace.hpp:79
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/System/Volumes/Data/mesos/work_dir/slaves/40f4774a-f408-4e28-8432-1004a7782450-S115964/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/7812c36d-6a7c-447b-8af2-3cb87f7004ed/runs/5974c193-703d-4fde-9521-6fbb5c740890/workspace/open/src/hotspot/share/memory/metaspace.hpp:79), pid=59568, tid=14083
#  assert(!_frozen) failed: sanity
#
# JRE version: Java(TM) SE Runtime Environment (17.0+25) (fastdebug build 17-ea+25-LTS-2176)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 17-ea+25-LTS-2176, interpreted mode, tiered, compressed class ptrs, z gc, bsd-aarch64)
# Core dump will be written. Default location: core.59568
#
# An error report file with more information is saved as:
# /System/Volumes/Data/mesos/work_dir/slaves/40f4774a-f408-4e28-8432-1004a7782450-S117909/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/7dc7c88a-6979-482d-b82f-3b567dd3165e/runs/8e011916-0489-4d53-afc4-a2e8751f2f97/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_runtime/scratch/0/hs_err_pid59568.log
[2.598s][info   ][cds       ] Gathering all archivable objects ... 
[2.598s][info   ][cds       ] Gathering classes and symbols ... 
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#
];
 stderr: []
 exitValue = 134

Here's the crashing thread's stack:

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

Current thread (0x000000010e808820):  ConcurrentGCThread "ZDriver" [stack: 0x0000000170398000,0x000000017059b000] [id=14083]

Stack: [0x0000000170398000,0x000000017059b000],  sp=0x000000017059ab80,  free space=2058k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.dylib+0xfcd4d0]  VMError::report_and_die(int, char const*, char const*, char*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long)+0x5d8
V  [libjvm.dylib+0xfcdb90]  VMError::report_and_die(Thread*, void*, char const*, int, char const*, char const*, char*)+0x40
V  [libjvm.dylib+0x52dcb0]  report_vm_error(char const*, int, char const*, char const*, ...)+0x80
V  [libjvm.dylib+0x4a3420]  ClassLoaderMetaspace::~ClassLoaderMetaspace()+0x50
V  [libjvm.dylib+0x49973c]  ClassLoaderData::~ClassLoaderData()+0x1b8
V  [libjvm.dylib+0x49ea58]  ClassLoaderDataGraph::purge(bool)+0x2c
V  [libjvm.dylib+0x1073f10]  ZUnload::purge()+0xa4
V  [libjvm.dylib+0x1038134]  ZHeap::process_non_strong_references()+0x64
V  [libjvm.dylib+0x1033b7c]  ZDriver::concurrent_process_non_strong_references()+0x8c
V  [libjvm.dylib+0x1034200]  ZDriver::gc(GCCause::Cause)+0x7c
V  [libjvm.dylib+0x1034358]  ZDriver::run_service()+0xa0
V  [libjvm.dylib+0x50ef80]  ConcurrentGCThread::run()+0x34
V  [libjvm.dylib+0xf30c34]  Thread::call_run()+0x21c
V  [libjvm.dylib+0xd08af0]  thread_native_entry(Thread*)+0x160
C  [libsystem_pthread.dylib+0x706c]  _pthread_start+0x140

=================================
Java Threads: ( => current thread )
  0x0000000118808e20 JavaThread "main" [_thread_blocked, id=5891, stack(0x000000016f12c000,0x000000016f32f000)]
  0x000000011e812420 JavaThread "Reference Handler" daemon [_thread_blocked, id=41731, stack(0x00000001713f8000,0x00000001715fb000)]
  0x000000011e815220 JavaThread "Finalizer" daemon [_thread_blocked, id=41219, stack(0x0000000171604000,0x0000000171807000)]
  0x000000011e813620 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=24335, stack(0x0000000171928000,0x0000000171b2b000)]
  0x000000011e814220 JavaThread "Service Thread" daemon [_thread_blocked, id=39939, stack(0x0000000171b34000,0x0000000171d37000)]
  0x000000011e817a20 JavaThread "Monitor Deflation Thread" daemon [_thread_blocked, id=39427, stack(0x0000000171d40000,0x0000000171f43000)]
  0x000000011e818620 JavaThread "Notification Thread" daemon [_thread_blocked, id=24835, stack(0x0000000171f4c000,0x000000017214f000)]
  0x000000011e81fc20 JavaThread "Common-Cleaner" daemon [_thread_blocked, id=25347, stack(0x0000000172364000,0x0000000172567000)]

Other Threads:
  0x0000000100f73af0 VMThread "VM Thread" [stack: 0x00000001711ec000,0x00000001713ef000] [id=42243]
  0x00000001013b3ce0 WatcherThread [stack: 0x0000000172158000,0x000000017235b000] [id=25091]
  0x000000011ff1dd10 ConcurrentGCThread "ZDirector" [stack: 0x000000017018c000,0x000000017038f000] [id=17927]
=>0x000000010e808820 ConcurrentGCThread "ZDriver" [stack: 0x0000000170398000,0x000000017059b000] [id=14083]
  0x000000010ff05ea0 ConcurrentGCThread "ZStat" [stack: 0x00000001705a4000,0x00000001707a7000] [id=17667]
  0x000000011ff1c8b0 ConcurrentGCThread "ZUnmapper" [stack: 0x000000016fd74000,0x000000016ff77000] [id=13315]
  0x000000010ff047e0 ConcurrentGCThread "ZUncommitter" [stack: 0x000000016ff80000,0x0000000170183000] [id=13571]
  0x000000011ff18650 GCTaskThread "ZWorker#0" [stack: 0x000000016f338000,0x000000016f53b000] [id=19971]
  0x000000011ff19380 GCTaskThread "ZWorker#1" [stack: 0x000000016f544000,0x000000016f747000] [id=12291]
  0x000000011ff19ff0 GCTaskThread "ZWorker#2" [stack: 0x000000016f750000,0x000000016f953000] [id=12803]
  0x000000011ff1ac60 GCTaskThread "ZWorker#3" [stack: 0x000000016f95c000,0x000000016fb5f000] [id=19459]
  0x000000011ff1b8d0 GCTaskThread "ZWorker#4" [stack: 0x000000016fb68000,0x000000016fd6b000] [id=18947]
  0x000000010fe11410 Thread "RuntimeWorker#0" [stack: 0x00000001707b0000,0x00000001709b3000] [id=16643]
  0x000000010fe12080 Thread "RuntimeWorker#1" [stack: 0x00000001709bc000,0x0000000170bbf000] [id=16387]
  0x000000010fe12cf0 Thread "RuntimeWorker#2" [stack: 0x0000000170bc8000,0x0000000170dcb000] [id=15875]
  0x000000011ff1ee30 Thread "RuntimeWorker#3" [stack: 0x0000000170dd4000,0x0000000170fd7000] [id=14851]
  0x000000010fe13960 Thread "RuntimeWorker#4" [stack: 0x0000000170fe0000,0x00000001711e3000] [id=15107]

Threads with active compile tasks:

VM state: at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread:  ([mutex/lock_event])
[0x000000010fe0a170] Threads_lock - owner thread: 0x0000000100f73af0
[0x000000010fe0b520] Heap_lock - owner thread: 0x0000000118808e20


Comments
Changeset: a8835b9c Author: Ioi Lam <iklam@openjdk.org> Date: 2021-06-02 19:20:10 +0000 URL: https://git.openjdk.java.net/jdk/commit/a8835b9c08af1438c80144bad7506fb5700511a3
02-06-2021

Metaspace::_frozen is set here: void VM_PopulateDumpSharedSpace::doit() { ... // We should no longer allocate anything from the metaspace, so that: // // (1) Metaspace::allocate might trigger GC if we have run out of // committed metaspace, but we can't GC because we're running // in the VM thread. // (2) ArchiveBuilder needs to work with a stable set of MetaspaceObjs. Metaspace::freeze(); Suggested fix: ClassLoaderMetaspace::~ClassLoaderMetaspace() { - Metaspace::assert_not_frozen(); + if (Metaspace::is_frozen()) { return; } void ClassLoaderMetaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) { - Metaspace::assert_not_frozen(); + if (Metaspace::is_frozen()) { return; }
31-05-2021