JDK-8229176 : Shenandoah should acquire CodeCache_lock without safepoint check
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 14
  • Priority: P1
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-08-06
  • Updated: 2020-11-23
  • Resolved: 2019-08-06
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
14 b09Fixed
Related Reports
Relates :  
Relates :  
Description
JDK-8229000 enabled the strong assert in Monitor::check_safepoint_state: it would fail when some locks are acquired with safepoint checks. There is such a lock in Shenandoah on a very common path. CodeCache_lock is defined with Monitor::_safepoint_check_never, should be acquired without safepoint check. New stronger assert fails because of that:

 #  Internal Error (/home/shade/trunks/jdk-jdk/src/hotspot/share/runtime/mutex.cpp:46), pid=27699, tid=27790
 #  assert(thread->is_Java_thread() || !do_safepoint_check || _safepoint_check_required != Monitor::_safepoint_check_never) failed: NonJavaThread should not check for safepoint

 V  [libjvm.so+0xff3399]  Monitor::check_safepoint_state(Thread*, bool)+0x119
 V  [libjvm.so+0xff33f1]  Monitor::lock(Thread*)+0x29
 V  [libjvm.so+0xff35fb]  Monitor::lock()+0x23
 V  [libjvm.so+0x119d62c] ShenandoahCodeRootsIterator::ShenandoahCodeRootsIterator()+0x10e
Comments
It does not apply to Shenandoah 8u, see JDK-8224115 for details
17-03-2020

Fix is already in sh/jdk11, dropping 11-shenandoah: http://hg.openjdk.java.net/shenandoah/jdk11/file/1c9e33ef2b1d/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp#l202
06-08-2019

URL: https://hg.openjdk.java.net/jdk/jdk/rev/758da77e4cd2 User: shade Date: 2019-08-06 09:57:57 +0000
06-08-2019

RFR: https://mail.openjdk.java.net/pipermail/shenandoah-dev/2019-August/010310.html
06-08-2019

Candidate fix: diff -r 8f067351c370 src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp --- a/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp Mon Aug 05 16:27:30 2019 -0700 +++ b/src/hotspot/share/gc/shenandoah/shenandoahCodeRoots.cpp Tue Aug 06 10:56:54 2019 +0200 @@ -201,5 +201,5 @@ } case 2: { - CodeCache_lock->lock(); + CodeCache_lock->lock_without_safepoint_check(); break; }
06-08-2019