Blame SOURCES/jdk8228407-shared_archive_crash.patch

e6bd67
# HG changeset patch
e6bd67
# User ccheung
e6bd67
# Date 1564075552 25200
e6bd67
#      Thu Jul 25 10:25:52 2019 -0700
e6bd67
# Node ID 1edf6cc224fbf975eadf2a1810f67816a8607d30
e6bd67
# Parent  73dbc713d4ddbdbeae71375db1603d85cef47f99
e6bd67
8228407: JVM crashes with shared archive file mismatch
e6bd67
Summary: Stop processing other header fields if initial header check has failed.
e6bd67
Reviewed-by: dholmes, jiangli
e6bd67
e6bd67
diff --git a/src/hotspot/share/memory/filemap.cpp b/src/hotspot/share/memory/filemap.cpp
e6bd67
--- a/src/hotspot/share/memory/filemap.cpp
e6bd67
+++ b/src/hotspot/share/memory/filemap.cpp
e6bd67
@@ -1287,7 +1287,9 @@
e6bd67
   }
e6bd67
 
e6bd67
   init_from_file(_fd);
e6bd67
-  if (!validate_header()) {
e6bd67
+  // UseSharedSpaces could be disabled if the checking of some of the header fields in
e6bd67
+  // init_from_file has failed.
e6bd67
+  if (!UseSharedSpaces || !validate_header()) {
e6bd67
     return false;
e6bd67
   }
e6bd67
   return true;
e6bd67
diff --git a/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java b/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java
e6bd67
--- a/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java
e6bd67
+++ b/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java
e6bd67
@@ -385,8 +385,16 @@
e6bd67
         output.shouldNotContain("Checksum verification failed");
e6bd67
 
e6bd67
         copyFile(orgJsaFile, jsa);
e6bd67
+        // modify _jvm_ident and run with -Xshare:auto
e6bd67
+        System.out.println("\n2b. Corrupt _jvm_ident run with -Xshare:auto\n");
e6bd67
+        modifyJvmIdent();
e6bd67
+        output = TestCommon.execAuto(execArgs);
e6bd67
+        output.shouldContain("The shared archive file was created by a different version or build of HotSpot");
e6bd67
+        output.shouldContain("Hello World");
e6bd67
+
e6bd67
+        copyFile(orgJsaFile, jsa);
e6bd67
         // modify _magic and _paths_misc_info_size, test should fail
e6bd67
-        System.out.println("\n2b. Corrupt _magic and _paths_misc_info_size, should fail\n");
e6bd67
+        System.out.println("\n2c. Corrupt _magic and _paths_misc_info_size, should fail\n");
e6bd67
         modifyHeaderIntField(offset_magic, 0x00000000);
e6bd67
         modifyHeaderIntField(offset_paths_misc_info_size, Integer.MAX_VALUE);
e6bd67
         output = TestCommon.execCommon(execArgs);
e6bd67
@@ -395,7 +403,7 @@
e6bd67
 
e6bd67
         copyFile(orgJsaFile, jsa);
e6bd67
         // modify _version and _paths_misc_info_size, test should fail
e6bd67
-        System.out.println("\n2c. Corrupt _version and _paths_misc_info_size, should fail\n");
e6bd67
+        System.out.println("\n2d. Corrupt _version and _paths_misc_info_size, should fail\n");
e6bd67
         modifyHeaderIntField(offset_version, 0x00000000);
e6bd67
         modifyHeaderIntField(offset_paths_misc_info_size, Integer.MAX_VALUE);
e6bd67
         output = TestCommon.execCommon(execArgs);