JDK-8201826 : G1: Don't invoke WeakProcessor if mark stack has overflowed
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2018-04-18
  • Updated: 2018-08-16
  • Resolved: 2018-04-23
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 11
11 b11Fixed
Related Reports
Relates :  
Description
I noticed this snippet in g1ConcurrentMark.cpp:

1706   if (has_overflown()) {
1707     // We can not trust g1_is_alive if the marking stack overflowed
1708     return;
1709   }

This was added by JDK-8036673.

And the comment is correct; if the mark stack overflows then g1_is_alive (a G1CMIsAliveClosure) can return false for a live object. (Said overflow and wrong answer can only happen because of soft reference phase1 or finalizer reference processing, as those are the only cases where previously unknown live objects can be found during reference processing.)

But all the j.l.r.Reference processing and the JNI &etc weak processing preceed that check.  Even after the JNI &etc weak processing was moved from ReferenceProcessor to WeakProcessor, the WeakProcessor invocation was placed between the ReferenceProcessor work and the overflow check.

The WeakProcessor invocation should be moved to after the overflow check.