JDK-8342334 : CDS: Scratch mirrors should not point to dead klasses
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 21,23,24
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-10-16
  • Updated: 2024-10-21
  • Resolved: 2024-10-21
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 24
24 masterFixed
Related Reports
Blocks :  
Description
When testing JDK-8341913, I have seen crashes that look like java.lang.Class mirror (CM) pointing to a dead InstanceKlass (IK). That CM is still alive from GC perspective. There is a 1:1 link IK->CM and CM->IK. Normal IK deallocation code nullptr-s the link between CM and IK when deallocating, and the rest of the code checks if CM's link to IK is nullptr. So when IK is deallocated, its relevant CM does not point to any garbage IK anymore.

However, CDS dumping code produces another "scratch" CM* -> IK. IK knows only about original CM, and not about the additional CM*. CDS code tries to clean it up when IK is deallocating, but it does so incompletely: it does not break the link between scratch CM* and IK, like the normal path does. So after class unloading, we have a "live" scratch CM* mirror that points to dead IK, and GC crashes.

We should break the link between scratch CM* and their IK in CDS dumping code as well.
Comments
Changeset: aa060f22 Branch: master Author: Aleksey Shipilev <shade@openjdk.org> Date: 2024-10-21 08:04:12 +0000 URL: https://git.openjdk.org/jdk/commit/aa060f22d302789c4f80dd1ebaa233a97b6b0073
21-10-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/21531 Date: 2024-10-16 09:57:47 +0000
16-10-2024