JDK-8268589 : appcds/SharedArchiveConsistency.java fails intermittently with java.lang.NegativeArraySizeException
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 11
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • Submitted: 2021-06-11
  • Updated: 2021-11-25
  • Resolved: 2021-06-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11.0.13-oracle b01Fixed
Related Reports
Relates :  
Description
Test case : open/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java

OS : Failure only seen on Windows-debug (Windows-2016)
Regression : Intermittent failure (can't say)


Exception :

2. Corrupt header, should fail

offset_paths_misc_info_size = 744
path_misc_info_size   = -1296882632
file_header_size      = -1296881848
file_header_size (aligned to page) = -1296879616
----------System.err:(14/922)----------
java.lang.NegativeArraySizeException: -1296879616
	at SharedArchiveConsistency.modifyJsaHeader(SharedArchiveConsistency.java:248)
	at SharedArchiveConsistency.main(SharedArchiveConsistency.java:395)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
	at java.base/java.lang.Thread.run(Thread.java:834)
Comments
11u notice I looked at the backport to 11u. The proposed patch above works with some adaptions. I tried to prove it fixes the error, but I could not reproduce the error. I also tried below patch, but it did not reproduce the issue, either. So I refrained from pushing that patch. --- a/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java +++ b/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java @@ -109,6 +110,11 @@ public class SharedArchiveConsistency { System.out.println("file_header_size = " + file_header_size); file_header_size = (int)align_up_page(file_header_size); System.out.println("file_header_size (aligned to page) = " + file_header_size); + + // GL Check for 8268589 + if (file_header_size > 1024*1024) { + throw new Exception("8268589: file header size too big"); + } return file_header_size; }
25-11-2021

This issue is no longer applicable since JDK 14. The offending code has been removed in JDK-8227370.
15-06-2021

Please try this patch. The calculation of offset_paths_misc_info_size is wrong. It usually gives a large positive number so the test would somehow work (but doesn't test what it intends to), but sometimes you get a negative number and see this failure. ================ wrong output and fails (as reported in bug description) 2. Corrupt header, should fail offset_paths_misc_info_size = 744 path_misc_info_size = -1296882632 file_header_size = -1296881848 file_header_size (aligned to page) = -1296879616 ================ wrong output but does not fail 2. Corrupt header, should fail offset_paths_misc_info_size = 744 path_misc_info_size = 10936432 file_header_size = 10937216 file_header_size (aligned to page) = 10940416 ================ patch diff --git a/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java b/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java index 74822604e3..e687186f46 100644 --- a/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java +++ b/test/hotspot/jtreg/runtime/appcds/SharedArchiveConsistency.java @@ -91,6 +91,7 @@ public class SharedArchiveConsistency { offset_magic = wb.getOffsetForName("FileMapHeader::_magic") - first_field_offset; offset_version = wb.getOffsetForName("FileMapHeader::_version") - first_field_offset; offset_jvm_ident = wb.getOffsetForName("FileMapHeader::_jvm_ident") - first_field_offset; + offset_paths_misc_info_size = wb.getOffsetForName("FileMapHeader::_paths_misc_info_size") - first_field_offset; sp_offset_crc = wb.getOffsetForName("space_info::_crc"); try { int nonExistOffset = wb.getOffsetForName("FileMapHeader::_non_exist_offset"); @@ -113,8 +114,6 @@ public class SharedArchiveConsistency { // this is not real header size, it is struct size int_size = wb.getOffsetForName("int_size"); file_header_size = wb.getOffsetForName("file_header_size"); - offset_paths_misc_info_size = wb.getOffsetForName("FileMapHeader::_paths_misc_info_size") - - offset_magic; int path_misc_info_size = (int)readInt(fc, offset_paths_misc_info_size, int_size); file_header_size += path_misc_info_size; System.out.println("offset_paths_misc_info_size = " + offset_paths_misc_info_size); =============== correct output after fix 2. Corrupt header, should fail offset_paths_misc_info_size = 728 path_misc_info_size = 70 file_header_size = 854 file_header_size (aligned to page) = 4096
11-06-2021