OpenJDK / jdk / jdk
changeset 55848:1edf6cc224fb
8228407: JVM crashes with shared archive file mismatch
Summary: Stop processing other header fields if initial header check has failed.
Reviewed-by: dholmes, jiangli
author | ccheung |
---|---|
date | Thu, 25 Jul 2019 10:25:52 -0700 |
parents | 73dbc713d4dd |
children | 691ce25ee015 |
files | src/hotspot/share/memory/filemap.cpp test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java |
diffstat | 2 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/hotspot/share/memory/filemap.cpp Thu Jul 25 21:21:29 2019 +0800 +++ b/src/hotspot/share/memory/filemap.cpp Thu Jul 25 10:25:52 2019 -0700 @@ -1610,7 +1610,9 @@ } init_from_file(_fd, is_static); - if (!validate_header(is_static)) { + // UseSharedSpaces could be disabled if the checking of some of the header fields in + // init_from_file has failed. + if (!UseSharedSpaces || !validate_header(is_static)) { return false; } return true;
--- a/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java Thu Jul 25 21:21:29 2019 +0800 +++ b/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java Thu Jul 25 10:25:52 2019 -0700 @@ -418,8 +418,16 @@ output.shouldNotContain("Checksum verification failed"); copyFile(orgJsaFile, jsa); + // modify _jvm_ident and run with -Xshare:auto + System.out.println("\n2b. Corrupt _jvm_ident run with -Xshare:auto\n"); + modifyJvmIdent(); + output = TestCommon.execAuto(execArgs); + output.shouldContain("The shared archive file was created by a different version or build of HotSpot"); + output.shouldContain("Hello World"); + + copyFile(orgJsaFile, jsa); // modify _magic and _paths_misc_info_size, test should fail - System.out.println("\n2b. Corrupt _magic and _paths_misc_info_size, should fail\n"); + System.out.println("\n2c. Corrupt _magic and _paths_misc_info_size, should fail\n"); modifyHeaderIntField(offset_magic, 0x00000000); modifyHeaderIntField(offset_paths_misc_info_size, Integer.MAX_VALUE); output = TestCommon.execCommon(execArgs); @@ -428,7 +436,7 @@ copyFile(orgJsaFile, jsa); // modify _version and _paths_misc_info_size, test should fail - System.out.println("\n2c. Corrupt _version and _paths_misc_info_size, should fail\n"); + System.out.println("\n2d. Corrupt _version and _paths_misc_info_size, should fail\n"); modifyHeaderIntField(offset_version, 0x00000000); modifyHeaderIntField(offset_paths_misc_info_size, Integer.MAX_VALUE); output = TestCommon.execCommon(execArgs);