JDK-8292499 : CDS ArchivedEnumTest.java fails: object points to a static field that may be reinitialized
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 20
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2022-08-16
  • Updated: 2022-12-14
  • Resolved: 2022-08-19
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 20
20 b12Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Sub Tasks
JDK-8292510 :  
Description
The following test failed in the JDK20 CI:

runtime/cds/appcds/cacheObject/ArchivedEnumTest.java

Here's a snippet from the log file:

#section:driver
----------messages:(5/150)----------
command: driver ArchivedEnumTest
reason: User specified action: run driver ArchivedEnumTest 
Mode: agentvm
Agent id: 13
elapsed time (seconds): 1.443
----------configuration:(18/2597)----------

<snip>

----------System.out:(11/4642)----------
Command line: [/opt/mach5/mesos/work_dir/jib-master/install/jdk-20+11-642/linux-aarch64-debug.jdk/jdk-20/fastdebug/bin/java -cp /opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S65203/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/23099d70-9761-4af7-aafd-747dc79940b2/runs/907e655f-1254-41ba-ade5-c755c1ee1560/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_tier2_runtime/classes/3/runtime/cds/appcds/cacheObject/ArchivedEnumTest.d:/opt/mach5/mesos/work_dir/jib-master/install/jdk-20+11-642/src.full/open/test/hotspot/jtreg/runtime/cds/appcds/cacheObject:/opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S65203/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/23099d70-9761-4af7-aafd-747dc79940b2/runs/907e655f-1254-41ba-ade5-c755c1ee1560/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_tier2_runtime/classes/3/test/lib:/opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S65203/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/23099d70-9761-4af7-aafd-747dc79940b2/runs/907e655f-1254-41ba-ade5-c755c1ee1560/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_tier2_runtime/classes/3/test/hotspot/jtreg/runtime/cds/appcds:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/6.1/1/bundles/jtreg-6.1+1.zip/jtreg/lib/javatest.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/6.1/1/bundles/jtreg-6.1+1.zip/jtreg/lib/jtreg.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/6.1/1/bundles/jtreg-6.1+1.zip/jtreg/lib/junit.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/6.1/1/bundles/jtreg-6.1+1.zip/jtreg/lib/hamcrest.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/6.1/1/bundles/jtreg-6.1+1.zip/jtreg/lib/testng.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/6.1/1/bundles/jtreg-6.1+1.zip/jtreg/lib/jcommander.jar:/opt/mach5/mesos/work_dir/jib-master/install/jtreg/6.1/1/bundles/jtreg-6.1+1.zip/jtreg/lib/guice.jar -XX:MaxRAMPercentage=6.25 -Djava.io.tmpdir=/opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S65203/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/23099d70-9761-4af7-aafd-747dc79940b2/runs/907e655f-1254-41ba-ade5-c755c1ee1560/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_tier2_runtime/tmp -cp /opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S65203/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/23099d70-9761-4af7-aafd-747dc79940b2/runs/907e655f-1254-41ba-ade5-c755c1ee1560/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_tier2_runtime/scratch/2/ArchivedEnumApp.jar -Xshare:dump -Xlog:cds -XX:SharedArchiveFile=/opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S65203/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/23099d70-9761-4af7-aafd-747dc79940b2/runs/907e655f-1254-41ba-ade5-c755c1ee1560/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_tier2_runtime/scratch/2/appcds-20h03m46s952.jsa -XX:ExtraSharedClassListFile=/opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S65203/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/23099d70-9761-4af7-aafd-747dc79940b2/runs/907e655f-1254-41ba-ade5-c755c1ee1560/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_tier2_runtime/scratch/2/runtime.cds.appcds.cacheObject.ArchivedEnumTest.java-test.classlist ]
[2022-08-16T20:03:46.997203145Z] Gathering output for process 1431910
[ELAPSED: 1262 ms]
[logging stdout to /opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S65203/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/23099d70-9761-4af7-aafd-747dc79940b2/runs/907e655f-1254-41ba-ade5-c755c1ee1560/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_tier2_runtime/scratch/2/runtime.cds.appcds.cacheObject.ArchivedEnumTest.java-0000-dump.stdout]
[logging stderr to /opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S65203/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/23099d70-9761-4af7-aafd-747dc79940b2/runs/907e655f-1254-41ba-ade5-c755c1ee1560/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_tier2_runtime/scratch/2/runtime.cds.appcds.cacheObject.ArchivedEnumTest.java-0000-dump.stderr]
[STDERR]

[2022-08-16T20:03:48.259513650Z] Waiting for completion for process 1431910
[2022-08-16T20:03:48.259828049Z] Waiting for completion finished for process 1431910
[2022-08-16T20:03:48.259940129Z] Waiting for completion for process 1431910
[2022-08-16T20:03:48.259983369Z] Waiting for completion finished for process 1431910
----------System.err:(86/6220)----------
 stdout: [[0.013s][info][cds] Core region alignment: 65536
[0.078s][info][cds] JVM_StartThread() ignored: java.lang.ref.Reference$ReferenceHandler
[0.078s][info][cds] JVM_StartThread() ignored: java.lang.ref.Finalizer$FinalizerThread
[0.124s][info][cds] JVM_StartThread() ignored: jdk.internal.misc.InnocuousThread
[0.157s][info][cds] Loading classes to share ...
[0.407s][info][cds] Loading classes to share: done.
[0.407s][info][cds] Shared spaces: preloaded 1322 classes
[0.408s][info][cds] Rewriting and linking classes ...
[0.408s][info][cds] Regenerate MethodHandle Holder classes...
[0.631s][info][cds] Regenerate MethodHandle Holder classes...done
[0.653s][info][cds] Rewriting and linking classes: done
[0.655s][info][cds] Run GC ...
[0.730s][info][cds] Run GC done
[0.732s][info][cds] Gathering all archivable objects ... 
[0.732s][info][cds] Gathering classes and symbols ... 
[0.856s][info][cds] Sorting symbols and fixing identity hash ... 
[0.860s][info][cds] Sorting classes ... 
[1.018s][info][cds] _estimated_hashtable_bytes = 386240 + 40624 = 426864
[1.018s][info][cds] _estimated_metaspaceobj_bytes = 222733376
[1.018s][info][cds] total estimate bytes = 223291312
[1.018s][info][cds] Reserved output buffer space at 0x0000fffe16b00000 [223346688 bytes]
[1.018s][info][cds] Allocating RW objects ... 
[1.032s][info][cds] done (28119 objects)
[1.032s][info][cds] Allocating RO objects ... 
[1.074s][info][cds] done (81057 objects)
[1.074s][info][cds] Relocating embedded pointers in core regions ... 
[1.132s][info][cds] Heap range = [0x0000000084000000 - 0x0000000100000000]
[1.132s][info][cds] Dumping objects to closed archive heap region ...
[1.144s][info][cds] Dumping objects to open archive heap region ...
[1.174s][info][cds] archived obj roots[2275] = 1140 words, klass = 0x100059da0, obj = 0xffe76340
[1.177s][warning][cds,heap] Archive heap points to a static field that may be reinitialized at runtime:
[1.177s][warning][cds,heap] Field: java/lang/reflect/AccessFlag$Location::EMPTY_SET
[1.177s][warning][cds,heap] Value: java.util.ImmutableCollections$SetN 
[1.177s][warning][cds,heap] {0x0000000084115ad0} - klass: 'java/util/ImmutableCollections$SetN'
[1.177s][warning][cds,heap]  - ---- fields (total size 3 words):
[1.177s][warning][cds,heap]  - final synchronized 'size' 'I' @12  0
[1.177s][warning][cds,heap]  - final synchronized 'elements' '[Ljava/lang/Object;' @16  a 'java/lang/Object'[0] {0x0000000084115ae8} (84115ae8)
[1.177s][warning][cds,heap] --- trace begin ---
[1.177s][warning][cds,heap] [ 0] {0x0000000084193f68} jdk.internal.module.ArchivedModuleGraph::finder (offset = 16)
[1.177s][warning][cds,heap] [ 1] {0x0000000084171ca0} jdk.internal.module.SystemModuleFinders$SystemModuleFinder::mrefs (offset = 12)
[1.177s][warning][cds,heap] [ 2] {0x0000000084171cb8} java.util.ImmutableCollections$SetN::elements (offset = 16)
[1.177s][warning][cds,heap] [ 3] {0x0000000084171cd0} [Ljava.lang.Object; @[1]
[1.177s][warning][cds,heap] [ 4] {0x000000008416ecd8} jdk.internal.module.ModuleReferenceImpl::descriptor (offset = 12)
[1.177s][warning][cds,heap] [ 5] {0x000000008415f948} java.lang.module.ModuleDescriptor::modifiers (offset = 32)::opens (offset = 44)
[1.177s][warning][cds,heap] [ 6] {0x0000000084115ad0} java.util.ImmutableCollections$SetN
[1.177s][warning][cds,heap] --- trace end ---
[1.177s][warning][cds,heap] 
[1.177s][warning][cds,heap] Scanned 23853 objects. Found 1 case(s) where an object points to a static field that may be reinitialized at runtime.
[1.180s][info   ][cds     ] Relocating external roots ... 
[1.182s][info   ][cds     ] done
[1.182s][info   ][cds     ] Dumping symbol table ...
[1.208s][info   ][cds     ] Relocating vmClasses::_klasses[] ... 
[1.208s][info   ][cds     ] Make classes shareable
[1.223s][info   ][cds     ] Number of classes 1486
[1.223s][info   ][cds     ]     instance classes   =  1367
[1.223s][info   ][cds     ]       boot             =  1366
[1.223s][info   ][cds     ]       app              =     1
[1.223s][info   ][cds     ]       platform         =     0
[1.223s][info   ][cds     ]       unregistered     =     0
[1.223s][info   ][cds     ]       (hidden)         =    91
[1.223s][info   ][cds     ]       (unlinked)       =     0
[1.223s][info   ][cds     ]     obj array classes  =   110
[1.223s][info   ][cds     ]     type array classes =     9
[1.223s][info   ][cds     ]                symbols = 41398
[1.230s][info   ][cds     ] Dumping shared data to file: 
[1.230s][info   ][cds     ]    /opt/mach5/mesos/work_dir/slaves/0c72054a-24ab-4dbb-944f-97f9341a1b96-S65203/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/23099d70-9761-4af7-aafd-747dc79940b2/runs/907e655f-1254-41ba-ade5-c755c1ee1560/testoutput/test-support/jtreg_open_test_hotspot_jtreg_hotspot_tier2_runtime/scratch/2/appcds-20h03m46s952.jsa
[1.235s][info   ][cds     ] Shared file region (rw )  0:  5245816 bytes, addr 0x0000000800000000 file offset 0x00010000 crc 0x2765ad12
[1.243s][info   ][cds     ] Shared file region (ro )  1:  8333776 bytes, addr 0x0000000800510000 file offset 0x00520000 crc 0x4db2effd
[1.244s][info   ][cds     ] Shared file region (bm )  2:   247976 bytes, addr 0x0000000000000000 file offset 0x00d20000 crc 0x1d7cc043
[1.245s][info   ][cds     ] Shared file region (ca0)  3:   589824 bytes, addr 0x00000000fff00000 file offset 0x00d60000 crc 0x32a1c991
[1.245s][info   ][cds     ] Shared file region (oa0)  5:   524288 bytes, addr 0x00000000ffe00000 file offset 0x00df0000 crc 0xcc384f11
];
 stderr: []
 exitValue = 0

java.lang.RuntimeException: 'object points to a static field that may be reinitialized at runtime' found in stdout
	at jdk.test.lib.process.OutputAnalyzer.shouldNotContain(OutputAnalyzer.java:267)
	at ArchivedEnumTest.main(ArchivedEnumTest.java:49)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:578)
	at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:312)
	at java.base/java.lang.Thread.run(Thread.java:1589)

JavaTest Message: Test threw exception: java.lang.RuntimeException
JavaTest Message: shutting down test

result: Failed. Execution failed: `main' threw exception: java.lang.RuntimeException: 'object points to a static field that may be reinitialized at runtime' found in stdout
Comments
Changeset: 964aac28 Author: Ioi Lam <iklam@openjdk.org> Date: 2022-08-19 03:04:08 +0000 URL: https://git.openjdk.org/jdk/commit/964aac28fe4a33f9e86cc07895a7ff4cdbaec3e6
19-08-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/9926 Date: 2022-08-18 19:56:30 +0000
18-08-2022

The check in cdsHeapVerifier.cpp is too strict and should be relaxed. AccessFlag$Location::EMPTY_SET is the same object as ImmutableCollections::EMPTY_SET, which is archived in the CDS heap. So at run time, we can guarantee that AccessFlag$Location::EMPTY_SET == ImmutableCollections::EMPTY_SET (... even if object equality may not be required by the AccessFlag class). The following patch fixes the test. I am trying to see if a more general fix can be done. diff --git a/src/hotspot/share/cds/cdsHeapVerifier.cpp b/src/hotspot/share/cds/cdsHeapVerifier.cpp index 1eff9116901..849ce6f14d4 100644 --- a/src/hotspot/share/cds/cdsHeapVerifier.cpp +++ b/src/hotspot/share/cds/cdsHeapVerifier.cpp @@ -101,6 +101,10 @@ CDSHeapVerifier::CDSHeapVerifier() : _archived_objs(0), _problems(0) "ALL_UNNAMED_MODULE_SET", // A "EVERYONE_MODULE", // A "EVERYONE_SET"); // A + + // This is the same as java/util/ImmutableCollections::EMPTY_SET, which is archived + ADD_EXCL("java/lang/reflect/AccessFlag$Location", "EMPTY_SET"); // E + ADD_EXCL("java/lang/System", "bootLayer"); // A ADD_EXCL("java/lang/VersionProps", "VENDOR_URL_BUG", // C "VENDOR_URL_VM_BUG", // C
17-08-2022

Since this appears to be a regression, I'm bumping the priority from P3 -> P2.
16-08-2022

ArchivedEnumTest.java was created to catch similar problems as found in JDK-8275731. We probably need a similar fix. See https://github.com/openjdk/jdk/pull/6653
16-08-2022

Added a new enum class to java.base...
16-08-2022

These test failures occurred in jdk-20+11-642-tier2 and that build-ID contains only once changset: JDK-8289106 Add model of class file versions to core reflection At first glance, it is not obvious (to me anyway) how [~darcy]'s fix could be related to this new test failure mode...
16-08-2022