JDK-8255282 : Compiler calls Dependencies::find_finalizable_subclass without Compile_lock
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 16
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • Submitted: 2020-10-23
  • Updated: 2020-11-18
  • Resolved: 2020-11-18
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 16
16Resolved
Related Reports
Relates :  
Description
ciInstanceKlass::has_finalizable_subclass() seems to be buggy. It should hold the Compile_lock, because Dependencies::find_finalizable_subclass walks Klass::_next_sibling, which is protected by Compile_lock

https://github.com/openjdk/jdk/blob/d8d91977127405c4c632add48f2bb310ad60c93c/src/hotspot/share/ci/ciInstanceKlass.cpp#L397

bool ciInstanceKlass::has_finalizable_subclass() {
  if (!is_loaded())     return true;
  VM_ENTRY_MARK;
  return Dependencies::find_finalizable_subclass(get_instanceKlass()) != NULL;
}

https://github.com/openjdk/jdk/blob/d8d91977127405c4c632add48f2bb310ad60c93c/src/hotspot/share/code/dependencies.cpp#L1536

Klass* Dependencies::find_finalizable_subclass(Klass* k) {
  if (k->is_interface()) return NULL;
  if (k->has_finalizer()) return k;
  k = k->subklass();
  while (k != NULL) {
    Klass* result = find_finalizable_subclass(k);
    if (result != NULL) return result;
    k = k->next_sibling();
  }
  return NULL;
}
Comments
[~thartmann] I fixed my comment above and closed this bug as Not an Issue.
26-10-2020

According to [~coleenp] The Klass::subklass and sibling links are intentionally lock free - they do not use the Compile_lock. The one instance of adding it under the Compile_lock is mostly left there for the other things under the lock, and the comment above Klass::subklass() is left there from an earlier implementation. That whole data structure was made lock free for concurrent class unloading.
26-10-2020

Did you mean "That whole data structure was made lock _free_ for concurrent class unloading."? Should we close this as "Not an Issue" then?
26-10-2020

ILW = Potential race condition in dependency handling code, no known failures (found by manual inspection), no workaround = MMH = P3
23-10-2020