8005076: Creating a CDS archive with one alignment and running another causes a crash.

Tue, 08 Jan 2013 13:38:11 -0500

author
hseigel
date
Tue, 08 Jan 2013 13:38:11 -0500
changeset 4397
561148896559
parent 4396
6c3f47d964f3
child 4399
185a2c979a0e

8005076: Creating a CDS archive with one alignment and running another causes a crash.
Summary: Save the alignment when writing the CDS and compare it when reading the CDS.
Reviewed-by: kvn, coleenp

src/share/vm/memory/filemap.cpp file | annotate | diff | comparison | revisions
src/share/vm/memory/filemap.hpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/arguments.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/globals.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/memory/filemap.cpp	Mon Jan 07 15:32:51 2013 -0500
     1.2 +++ b/src/share/vm/memory/filemap.cpp	Tue Jan 08 13:38:11 2013 -0500
     1.3 @@ -119,6 +119,7 @@
     1.4    _header._magic = 0xf00baba2;
     1.5    _header._version = _current_version;
     1.6    _header._alignment = alignment;
     1.7 +  _header._obj_alignment = ObjectAlignmentInBytes;
     1.8  
     1.9    // The following fields are for sanity checks for whether this archive
    1.10    // will function correctly with this JVM and the bootclasspath it's
    1.11 @@ -473,6 +474,12 @@
    1.12                    " version or build of HotSpot.");
    1.13      return false;
    1.14    }
    1.15 +  if (_header._obj_alignment != ObjectAlignmentInBytes) {
    1.16 +    fail_continue("The shared archive file's ObjectAlignmentInBytes of %d"
    1.17 +                  " does not equal the current ObjectAlignmentInBytes of %d.",
    1.18 +                  _header._obj_alignment, ObjectAlignmentInBytes);
    1.19 +    return false;
    1.20 +  }
    1.21  
    1.22    // Cannot verify interpreter yet, as it can only be created after the GC
    1.23    // heap has been initialized.
     2.1 --- a/src/share/vm/memory/filemap.hpp	Mon Jan 07 15:32:51 2013 -0500
     2.2 +++ b/src/share/vm/memory/filemap.hpp	Tue Jan 08 13:38:11 2013 -0500
     2.3 @@ -63,6 +63,7 @@
     2.4      int    _magic;                    // identify file type.
     2.5      int    _version;                  // (from enum, above.)
     2.6      size_t _alignment;                // how shared archive should be aligned
     2.7 +    int    _obj_alignment;            // value of ObjectAlignmentInBytes
     2.8  
     2.9      struct space_info {
    2.10        int    _file_offset;   // sizeof(this) rounded to vm page size
     3.1 --- a/src/share/vm/runtime/arguments.cpp	Mon Jan 07 15:32:51 2013 -0500
     3.2 +++ b/src/share/vm/runtime/arguments.cpp	Tue Jan 08 13:38:11 2013 -0500
     3.3 @@ -1331,14 +1331,14 @@
     3.4    // then a saved space from compressed oops.
     3.5    if ((int)ObjectAlignmentInBytes > 256) {
     3.6      jio_fprintf(defaultStream::error_stream(),
     3.7 -                "error: ObjectAlignmentInBytes=%d must not be greater then 256\n",
     3.8 +                "error: ObjectAlignmentInBytes=%d must not be greater than 256\n",
     3.9                  (int)ObjectAlignmentInBytes);
    3.10      return false;
    3.11    }
    3.12    // In case page size is very small.
    3.13    if ((int)ObjectAlignmentInBytes >= os::vm_page_size()) {
    3.14      jio_fprintf(defaultStream::error_stream(),
    3.15 -                "error: ObjectAlignmentInBytes=%d must be less then page size %d\n",
    3.16 +                "error: ObjectAlignmentInBytes=%d must be less than page size %d\n",
    3.17                  (int)ObjectAlignmentInBytes, os::vm_page_size());
    3.18      return false;
    3.19    }
    3.20 @@ -2997,11 +2997,6 @@
    3.21      FLAG_SET_DEFAULT(UseLargePages, false);
    3.22    }
    3.23  
    3.24 -  // Add 2M to any size for SharedReadOnlySize to get around the JPRT setting
    3.25 -  if (DumpSharedSpaces && !FLAG_IS_DEFAULT(SharedReadOnlySize)) {
    3.26 -    SharedReadOnlySize = 14*M;
    3.27 -  }
    3.28 -
    3.29    if (DumpSharedSpaces) {
    3.30      if (RequireSharedSpaces) {
    3.31        warning("cannot dump shared archive while using shared archive");
     4.1 --- a/src/share/vm/runtime/globals.hpp	Mon Jan 07 15:32:51 2013 -0500
     4.2 +++ b/src/share/vm/runtime/globals.hpp	Tue Jan 08 13:38:11 2013 -0500
     4.3 @@ -1830,7 +1830,7 @@
     4.4                                                                              \
     4.5    product(intx, CMSIsTooFullPercentage, 98,                                 \
     4.6            "An absolute ceiling above which CMS will always consider the "   \
     4.7 -          "perm gen ripe for collection")                                   \
     4.8 +          "unloading of classes when class unloading is enabled")           \
     4.9                                                                              \
    4.10    develop(bool, CMSTestInFreeList, false,                                   \
    4.11            "Check if the coalesced range is already in the "                 \
    4.12 @@ -1899,13 +1899,13 @@
    4.13            "Metadata deallocation alot interval")                            \
    4.14                                                                              \
    4.15    develop(bool, TraceMetadataChunkAllocation, false,                        \
    4.16 -          "Trace humongous metadata allocations")                           \
    4.17 +          "Trace chunk metadata allocations")                               \
    4.18                                                                              \
    4.19    product(bool, TraceMetadataHumongousAllocation, false,                    \
    4.20            "Trace humongous metadata allocations")                           \
    4.21                                                                              \
    4.22    develop(bool, TraceMetavirtualspaceAllocation, false,                     \
    4.23 -          "Trace humongous metadata allocations")                           \
    4.24 +          "Trace virtual space metadata allocations")                       \
    4.25                                                                              \
    4.26    notproduct(bool, ExecuteInternalVMTests, false,                           \
    4.27            "Enable execution of internal VM tests.")                         \
    4.28 @@ -3537,10 +3537,10 @@
    4.29    /* Shared spaces */                                                       \
    4.30                                                                              \
    4.31    product(bool, UseSharedSpaces, true,                                      \
    4.32 -          "Use shared spaces in the permanent generation")                  \
    4.33 +          "Use shared spaces for metadata")                                 \
    4.34                                                                              \
    4.35    product(bool, RequireSharedSpaces, false,                                 \
    4.36 -          "Require shared spaces in the permanent generation")              \
    4.37 +          "Require shared spaces for metadata")                             \
    4.38                                                                              \
    4.39    product(bool, DumpSharedSpaces, false,                                    \
    4.40             "Special mode: JVM reads a class list, loads classes, builds "   \
    4.41 @@ -3551,16 +3551,16 @@
    4.42            "Print usage of shared spaces")                                   \
    4.43                                                                              \
    4.44    product(uintx, SharedReadWriteSize,  NOT_LP64(12*M) LP64_ONLY(16*M),      \
    4.45 -          "Size of read-write space in permanent generation (in bytes)")    \
    4.46 +          "Size of read-write space for metadata (in bytes)")               \
    4.47                                                                              \
    4.48    product(uintx, SharedReadOnlySize,  NOT_LP64(12*M) LP64_ONLY(16*M),       \
    4.49 -          "Size of read-only space in permanent generation (in bytes)")     \
    4.50 +          "Size of read-only space for metadata (in bytes)")                \
    4.51                                                                              \
    4.52    product(uintx, SharedMiscDataSize,    NOT_LP64(2*M) LP64_ONLY(4*M),       \
    4.53 -          "Size of the shared data area adjacent to the heap (in bytes)")   \
    4.54 +          "Size of the shared miscellaneous data area (in bytes)")          \
    4.55                                                                              \
    4.56    product(uintx, SharedMiscCodeSize,    120*K,                              \
    4.57 -          "Size of the shared code area adjacent to the heap (in bytes)")   \
    4.58 +          "Size of the shared miscellaneous code area (in bytes)")          \
    4.59                                                                              \
    4.60    product(uintx, SharedDummyBlockSize, 0,                                   \
    4.61            "Size of dummy block used to shift heap addresses (in bytes)")    \

mercurial