JDK-8261860 : Crash caused by lambda proxy class loaded in Shutdown hook
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 15,16
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-02-16
  • Updated: 2021-03-09
  • Resolved: 2021-02-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 16 JDK 17
16.0.1Fixed 17 b11Fixed
Description
When creating a dynamic CDS archive with -XX:ArchiveClassesAtExit, if a lambda proxy class P is loaded inside a Shutdown hook, the proxy's nest_host class N may not be properly linked. This causes the N to be missing from the archive.

When P is loaded from the archive at run time, it require that N must also be in the archive. Since this is not the case, the VM crashes in subsequent operations.
Comments
Fix Request: The SQL team reported this bug. I think this should be backported to JDK16u so that the SQL team can continue using JDK16. The patch is simple and should apply cleanly to JDK16.
26-02-2021

Changeset: 78cde648 Author: Calvin Cheung <ccheung@openjdk.org> Date: 2021-02-19 02:40:03 +0000 URL: https://git.openjdk.java.net/jdk/commit/78cde648
19-02-2021

Attached test case for reproducing the bug. // compile the test case javac MyTest.java // create a test.jar jar cvf test.jar *.class // create an archive using dynamic dump java -XX:ArchiveClassesAtExit=foo.jsa -cp test.jar MyTest // run with the dynamic archive java -XX:SharedArchiveFile=foo.jsa -cp test.jar MyTest VM crashes due to the following assert failure in systemDictionaryShare.cpp: # assert(shared_nest_host != __null) failed: unexpected NULL _nest_host
17-02-2021

Proposed fix: since shutdown hooks are rarely considered to be part of an app's start-up time, it should be OK to exclude all classes loaded inside shutdown hooks from the CDS archive (whose primary purpose is to reduce start-up time). This bug happens because *regular* classes loaded inside shutdown hooks (N in Bug Description) are excluded from the archive, but lambda proxy classes (P) are not. A simple fix is to properly exclude P.
16-02-2021