JDK-8236487 : JFR Recorder Thread crashed due to "assert(_chunkwriter.is_valid()) failed: invariant"
  • Type: Bug
  • Component: hotspot
  • Sub-Component: jfr
  • Affected Version: 14
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2019-12-22
  • Updated: 2020-09-29
  • Resolved: 2020-01-08
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 14 JDK 15
14 b31Fixed 15Fixed
Related Reports
Relates :  
Description
The following test failed in the JDK14 CI:

applications/dacapo/Dacapo24H.java

Here's a snippet from the log file:Stress process main method is started.
[5907.517s][warning][gc] GC locker is held; pre-dump GC was skipped
[15170.498s][warning][gc] GC locker is held; pre-dump GC was skipped
[34972.718s][warning][gc] GC locker is held; pre-dump GC was skipped
[42555.613s][warning][gc] GC locker is held; pre-dump GC was skipped
[54672.111s][warning][gc] GC locker is held; pre-dump GC was skipped
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (open/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp:595), pid=31074, tid=31169
#  assert(_chunkwriter.is_valid()) failed: invariant
#
# JRE version: Java(TM) SE Runtime Environment (14.0+28) (fastdebug build 14-ea+28-1352)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 14-ea+28-1352, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0xd38915][thread 14293 also had an error]
  JfrRecorderService::invoke_flush()+0x715

Here's the crashing thread's stack:

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

Current thread (0x00007fc488048000):  JavaThread "JFR Recorder Thread" daemon [_thread_in_vm, id=31169, stack(0x00007fc4d05d5000,0x00007fc4d06d6000)]

Stack: [0x00007fc4d05d5000,0x00007fc4d06d6000],  sp=0x00007fc4d06d4bc0,  free space=1022k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0xd38915]  JfrRecorderService::invoke_flush()+0x715
V  [libjvm.so+0xd391b5]  JfrRecorderService::flushpoint()+0x65
V  [libjvm.so+0xd3b1e8]  recorderthread_entry(JavaThread*, Thread*)+0x168
V  [libjvm.so+0x15a0666]  JavaThread::thread_main_inner()+0x226
V  [libjvm.so+0x15a5896]  Thread::call_run()+0xf6
V  [libjvm.so+0x12d4c96]  thread_native_entry(Thread*)+0x116
Comments
URL: https://hg.openjdk.java.net/jdk/jdk14/rev/decd3d2953b6 User: egahlin Date: 2020-01-08 18:13:09 +0000
08-01-2020

ILW = HLM = P3
07-01-2020

Fix: diff -r 563fa900fa17 src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp --- a/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp Sat Dec 21 13:03:02 2019 +0100 +++ b/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp Sun Dec 22 17:23:54 2019 +0100 @@ -671,8 +671,10 @@ void JfrRecorderService::flushpoint() { MutexLocker lock(JfrStream_lock, Mutex::_no_safepoint_check_flag); + if (_chunkwriter.is_valid()) { invoke_flush(); } +} void JfrRecorderService::process_full_buffers() { if (_chunkwriter.is_valid()) {
22-12-2019

This happens as a consequence of an emergency dump (in this case trigged by OutOfMemory). The coordination over the JfrStream_lock is incomplete in that the thread issuing the emergency dump will close the underlying file descriptor (used by _chunkwriter) after the dump, but the flush() thread awaits for the emergency dump to complete (waits on JfrStream_lock).
22-12-2019