Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8199007

ClassLoaderDataGraph::unload_list_contains() is wrong

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 11
    • Fix Version/s: 11
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b10

      Description

      When working on some metaspace-related cleanup tasks, I saw that ClassLoaderDataGraph::unload_list_contains() seems wrong:

        for (ClassLoaderData* cld = _unloading; cld != NULL; cld = cld->next()) {
          if (cld->metaspace_or_null() != NULL && cld->metaspace_or_null()->contains(x)) {
            return true;
          }
        }

      There is no non-static Metaspace::contains. There are only two variants of static Metaspace::contains(), which test if the given pointer is somewhere in the metaspace, disregarding the classloader in question.

      In this case, this static function is called via an instance, which unfortunately is valid C++.

      This effects HeapRegion::verify:

              bool is_metaspace_object = Metaspace::contains(klass) ||
                                         (vo == VerifyOption_G1UsePrevMarking &&
                                         ClassLoaderDataGraph::unload_list_contains(klass));

      because ClassLoaderDataGraph::unload_list_contains(klass) returns true for any klass living in metaspace, not just klass objects which are part of this class loaders unload list.

      Although I am not sure I even understand the conditions: "Metaspace::contains(klass)" should always encompass "ClassLoaderDataGraph::unload_list_contains(klass)", or?

        Attachments

          Activity

            People

            Assignee:
            coleenp Coleen Phillimore
            Reporter:
            stuefe Thomas Stuefe
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: