RFR: 8285518: CDS assert: visibility cannot change between dump time and runtime

David Holmes dholmes at openjdk.java.net
Tue May 10 04:38:56 UTC 2022


On Mon, 25 Apr 2022 23:48:14 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> This PR fixes a timing hole in the CDS class loading code. The bug happens with the `jdk/internal/ref/Cleaner` class, which is loaded by the boot classloader.
> 
> - The loading of `Cleaner` is initiated
> - We look up the `pkg_entry` for this class
> - At this point, the module system is not yet fully initialized, so package information is not yet available, and we get `pkg_entry == NULL`
> - Later, in `SystemDictionary::is_shared_class_visible_impl`, we try to check the visbility of this class, but now the module system is fully initialized, so the NULL `pkg_entry` is no longer valid.
> 
> The fix is to always reload the  `pkg_entry` if it's NULL. This should happen very rarely because  `pkg_entry`  for archived classes are usually non-null.
> 
> This timing hole existed before but has been triggered (once) only after Loom changed the bootstrap sequence of the reference thread. Nonetheless we should backport to older JDKs since there's still a theoretical chance this it may happen, and the fix is simple.

Seems quite reasonable.

Thanks.

-------------

Marked as reviewed by dholmes (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/8392


More information about the hotspot-runtime-dev mailing list