JDK-8316132 : CDSProtectionDomain::get_shared_protection_domain should check for exception
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 11,17,21,22
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-09-12
  • Updated: 2024-02-22
  • Resolved: 2023-10-31
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 21 JDK 22
21.0.3Fixed 22 b22Fixed
Related Reports
Relates :  
Relates :  
Description
This bug was found when diagnosing JDK-8316131

Handle CDSProtectionDomain::get_shared_protection_domain(Handle class_loader,
                                                            int shared_path_index,
                                                            Handle url,
                                                            TRAPS) {
  Handle protection_domain;
  if (shared_protection_domain(shared_path_index) == nullptr) {
    Handle pd = get_protection_domain_from_classloader(class_loader, url, THREAD); <<<<< HERE
    atomic_set_shared_protection_domain(shared_path_index, pd());
  }

  // Acquire from the cache because if another thread beats the current one to
  // set the shared protection_domain and the atomic_set fails, the current thread
  // needs to get the updated protection_domain from the cache.
  protection_domain = Handle(THREAD, shared_protection_domain(shared_path_index));
  assert(protection_domain.not_null(), "sanity");  <<<<< HERE
  return protection_domain;
}

When we are really low on heap memory, the get_protection_domain_from_classloader() call may fail. Instead of THREAD, we should pass CHECK so that the exception is propagated properly.
Comments
[jdk21u-fix-request] Approval Request from Aleksey Shipilëv Clean backport to propagate CDS exceptions better. Should be low risk.
09-01-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk21u-dev/pull/144 Date: 2024-01-08 18:22:49 +0000
08-01-2024

Seems to be that way all the way back to initial integration of JDK-8188791. Files were reshuffled in JDK-8268821.
08-01-2024

Changeset: 11394828 Author: Calvin Cheung <ccheung@openjdk.org> Date: 2023-10-31 20:56:18 +0000 URL: https://git.openjdk.org/jdk/commit/11394828b32941a69d549bae613ab4c3afb713d5
31-10-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/16428 Date: 2023-10-30 22:52:29 +0000
30-10-2023

ILW = HLM = P3
12-09-2023