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

Reference count for PackageEntry::name may be incorrectly decremented

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 15
    • Fix Version/s: 16
    • Component/s: hotspot
    • Subcomponent:
    • Resolved In Build:
      b06

      Description

      See http://hg.openjdk.java.net/jdk/jdk/annotate/eee45238844e/src/hotspot/share/oops/instanceKlass.cpp#l2666

      TempNewSymbol pkg_name = pkg_entry != NULL ? pkg_entry->name() : ClassLoader::package_from_class_name(name());

      If pkg_entry->name() is stored into the TempNewSymbol, it's refcount is not incremented:

        // Conversion from a Symbol* to a TempNewSymbol.
        // Does not increment the current reference count.
        TempNewSymbol(Symbol *s) : _temp(s) {}

      but when the TempNewSymbol falls out of scope, we will call pkg_entry->name()->decrement_refcount():

        ~TempNewSymbol() {
          if (_temp != NULL) {
            _temp->decrement_refcount();
          }
        }

      this causes the refcount of pkg_entry->name() to decrease by 1 when InstanceKlass::set_package returns.

      This code was introduced in JDK-8240205 (there's a similar problem in systemDictionary.cpp). This has not caused any issue so far because we pkg_entry is non-NULL only for shared classes, whose package name is also a shared Symbol* with permanent refcount (-1), but logically this is incorrect and should be fixed to avoid future issues.

        Attachments

          Activity

            People

            Assignee:
            ccheung Calvin Cheung
            Reporter:
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: