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

HeapWord should not be a fake class

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 13
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
      gc
    • Resolved In Build:
      b09

      Description

      Memset is performed over HeapWord* which is "class {private: char* i;}" in

      src/hotspot/share/gc/parallel/objectStartArray.cpp: In member function 'void ObjectStartArray::set_covered_region(MemRegion)':
      src/hotspot/share/gc/parallel/objectStartArray.cpp:106:56: error: 'void* memset(void*, int, size_t)' writing to an object of type 'class HeapWord' with 'private' member 'HeapWord::i' [-Werror=class-memaccess]
           memset(_blocks_region.end(), clean_block, expand_by);
                                                              ^
      In file included from /src/hotspot/share/utilities/align.hpp:28,
                       from src/hotspot/share/runtime/globals.hpp:29,
                       from src/hotspot/share/memory/allocation.hpp:28,
                       from src/hotspot/share/classfile/classLoaderData.hpp:28,
                       from src/hotspot/share/precompiled/precompiled.hpp:34:
      src/hotspot/share/utilities/globalDefinitions.hpp:174:7: note: 'class HeapWord' declared here
       class HeapWord {
             ^~~~~~~~
         ... (rest of output omitted)

      HeapWord is defined as a "fake" class (with a private char* member) that is never really instantiated. -Wclass-memaccess is being triggered because the use of memset is bypassing access control to the data member of HeapWord.

      And clean_block is -1.

      Possible fix is to add (char*) cast similar to src/hotspot/share/gc/parallel/mutableNUMASpace.cpp

      Another approach is to add HeapWord constructor that sets i and use placement new.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kbarrett Kim Barrett
                Reporter:
                dchuyko Dmitry Chuyko
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: