JDK-8307236 : Rendezvous GC threads under STS for monitor deflation
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 17,20,21
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2023-05-02
  • Updated: 2023-08-17
  • Resolved: 2023-05-05
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 21
21 b22Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Description
Object monitors are deflated concurrently by the MonitorDeflationThread. It first unlinks monitors from objects (i.e. restore the original object header), then handshakes (with a no-op) all Java threads, and only then destroys the monitors. This way, Java threads can safely (and racily) access monitors before the handshake, because the monitors are guaranteed to still exist when a Java thread racily reads a mark-word that is being unlinked, and the monitor can safely be destroyed after the handshake, because all Java threads would then read the correct unlinked mark-word.

However, GC threads are not rendezvous'ed like that, and can read potentially dead monitors. This is a problem for compact object headers (JDK-8294992) because GC threads need to be able to safely access the Klass* which would then be stored in the object header, and might be displaced into a monitor.

In order to safely access monitors via object headers concurrently from GC threads, we need to rendezvous them after unlinking and before destroying the monitors, just like Java threads do, via handshake. This is important so that concurrent GCs (ZGC, Shenandoah, G1) can safely access object's Klass* (and thus object size, layout, etc) during concurrent GC phases.

Comments
Changeset: 12d6ec66 Author: Roman Kennke <rkennke@openjdk.org> Date: 2023-05-05 14:35:33 +0000 URL: https://git.openjdk.org/jdk/commit/12d6ec66a6cc668c929b3ebefd52a0dcac34771a
05-05-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/13773 Date: 2023-05-03 10:06:43 +0000
03-05-2023