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