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

UnifiedOopRef::encode_null() doesn't ensure initialization

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • tbd
    • 15
    • hotspot
    • jfr

      UnifiedOopRef has a single uintptr_t _value member.

      UnifiedOopRef::encode_null() returns UnifiedOopRef(). That's the implicitly declared default constructor. Such a constructor is specified to not initialize such a member [1][2]. encode_null() should be written as

      inline UnifiedOopRef UnifiedOopRef::encode_null() {
        UnifiedOopRef result = { 0 };
        return result;
      }

      It's probably just (questionable) luck that this hasn't shown up as crashes in the JFR leak profiler. (Or maybe it has, and I didn't find the JBS issue(s).)

      [1] Such a constructor "performs the set of initializations of the class that would be performed by a user-written default constructor ... with an empty mem-initializer-list and an empty function body." (C++03 12.1/7; updated wording but otherwise similar in C++14.)

      [2] If a data member is not named by a mem-initializer-id (including the case where there is no mem-initializer-list) and is not of class type, it is not initialized. (C++03 12.6.2/4; C++14 says this case is default initialized, but that's equivalent to uninitialized for the member's type.)

            Unassigned Unassigned
            kbarrett Kim Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: