JDK-8284435 : Add dedicated filler objects for known dead Java heap areas
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 19
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-04-06
  • Updated: 2023-11-06
  • Resolved: 2022-05-02
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 19
19 b21Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Currently, when formatting areas of dead objects all gcs use instances of j.l.Object and int-arrays.

This has the drawback of not being easily able to discern whether a given object is actually dead (and should never be referenced) or just a regular j.l.Object/int array.

Further, for enhanced error detection (any reference to such an object is an error) and to skip potentially already unloaded classes when scanning areas of the heap below TAMS, G1 uses its prev bitmap.
Other collectors do not have this extra information at the moment, so they can't (and don't) do this kind of verification.

With JDK-8210708 the prev bitmap will effectively be removed; G1 will format the dead areas with these filler objects to avoid coming across unloaded classes. This is fine wrt to normal operation, however, this looses the information about whether there is a reference to any dead object/dead area with verification turned on.

This change proposes to add dedicated VM-internal filler objects, i.e. equivalents of j.l.Object and int-arrays.

This has the following benefits:

- keep this error detection (actually making it much simpler) and allowing similar verification for other collectors.

- this also makes it "easy" to detect such errors in debugging tools - you only need to know the two klasses to see whether that reference may actually be valid (or refers to the inside such an object). References to these classes in the crash file may also allow the issue to be more clear.

This causes some minor changes to external behavior involved:

- logs/heap dumps now contain instances of these objects - which seems fine as previously they have just been reported as part of  j.l.Object/int-arrays statistics. The VM spec also does not guarantee whether a particular kind of object should/should not show there anyway.

- if the application ever gets to instantiate a reference to such an object somehow, any enabled verification will crash the VM.

The change will take care that getting a reference will not be possible by normal means (i.e. via Class.forName() etc) - which should be sufficient to avoid the issue.
Comments
Changeset: 70205956 Author: Thomas Schatzl <tschatzl@openjdk.org> Date: 2022-05-02 11:03:57 +0000 URL: https://git.openjdk.java.net/jdk/commit/70205956313740e48e1fcb0c02c8f1488ab0d987
02-05-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/8156 Date: 2022-04-08 08:13:33 +0000
08-04-2022