JDK-8280454 : G1: ClassLoaderData verification keeps CLDs live that causes problems with VerifyDuringGC during Remark
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 19
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-01-21
  • Updated: 2024-06-27
  • Resolved: 2022-06-10
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 20
20 b02Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
When running with -XX:+VerifyDuringGC G1 will do verification during the Remark and Cleanup pause. The "before" verification in Remark is causing class unloading to not work as expected because iterating over the CLDGs keeps all CLDs live. The call to ClassLoaderData::holder() in ClassLoaderDataGraphIterator::get_next() pushes it into the SATB queue, which is processed during Remark just a bit later.

At least for the TestHumongousClassLoader.java this causes a test failure as the CLDs are not unloaded. This can be reproduce using -XX:VerifySubSet=classloader_data_graph (i.e. only do that specific verification) and if you instead run with -XX:VerifySubSet=heap the tests passes.

One workaround could be to only verify the heap in the "before" verification for remark, exclude the CLDG verification in this verification or add a special iteration for this particular verification.
Comments
Changeset: 94b473e4 Author: Thomas Schatzl <tschatzl@openjdk.org> Date: 2022-06-10 07:57:32 +0000 URL: https://git.openjdk.org/jdk/commit/94b473e4642a5a4626faeb73341b4aea128ccb31
10-06-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8949 Date: 2022-05-30 17:09:35 +0000
31-05-2022

System dictionary verification has the same issue, the called method ClassLoaderDataGraph::verify_dictionary() keeps alive objects in error.
30-05-2022

My guess is that the ClassLoaderDataGraphIterator puts ClassLoaderData instances it finds into handles, which may keep them alive until they are cleaned out. Not sure exactly why they are marked as live throughout the remark pause as on the outside handling seems okay (i.e. some handlemark is used)
24-01-2022