JDK-7103238 : Ensure pending list lock is held on behalf of GC before enqueuing references on to the pending list
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 8
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-10-20
  • Updated: 2016-09-01
  • Resolved: 2016-09-01
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 9
9Fixed
Related Reports
Relates :  
Description
Currently, whenever a GC operation needs to enqueue reference objects on to the ReferenceHandler thread's pending list, the GC is supposed to synchronize with the ReferenceHandler thread. This synchronization is achieved by means of the pending list lock. The pending list lock is a Java level monitor and the ReferenceHandler thread owns the monitor while draining the pending list - periodically releasing and waiting on the monitor.

Since the pending list lock is a Java level monitor - non Java threads can't lock it directly.

During a typical GC, the pending list lock is obtained in the gc_prologue() method of the GC VM_Operation. This method is executed by the thread requesting the GC - a Java thread - so it can directly lock the pending list lock.

With concurrent GC operations the thread requesting the VM operation is usually a ConcurrentGCThread and not a Java thread. Thus it can't manipulate the pending list lock directly. Instead it employs the SurrogateLockerThread. The SLT is a daemon Java thread whose raison d'etre is to maniplate (acquire and release) the pending list lock on behalf of the non-Java concurrent GC thread.

Recently we had a case where the pending_list lock was not held on behalf of a concurrent GC operation that pused reference objects on to the pending list. See CR 7099824.

To avoid this situation in the future we should check that the pending list lock is held on behalf of the GC before enqueuing any reference objects.

A suitable and simple check could be to record the thread requesting a particular VM operation and check that the PLL is held by the requesting thread or the SLT prior to enqueuing.

Comments
The ReferencePendingListLockerThread (formerly the SurrogateLockerThread) was eliminated by JDK-8156500. We are now just expected to hold the Heap_lock when manipulating the (now in the VM) pending list.
01-09-2016