See https://github.com/openjdk/jdk/blob/0aa63feca8704c8958530ef9e3df128570c50e12/src/hotspot/share/cds/metaspaceShared.cpp#L579
// There may be pending VM operations. We have changed some global states
// (such as vmClasses::_klasses) that may cause these VM operations
// to fail. For safety, forget these operations and exit the VM directly.
vm_direct_exit(0);
This is unsafe because C++ global destructors may be executed as a result of calling vm_direct_exit. This may cause a race condition with concurrent GC threads that are updating global objects and result in a crash.
Suggested fix:
- As a hack, we could call _exit(), which will quit the process without doing global cleanups
- But a more wholesome fix would be to avoid modifying the global states (such as vmClasses::_klasses) during -Xshare:dump. This should be fairly easy to implement.
// There may be pending VM operations. We have changed some global states
// (such as vmClasses::_klasses) that may cause these VM operations
// to fail. For safety, forget these operations and exit the VM directly.
vm_direct_exit(0);
This is unsafe because C++ global destructors may be executed as a result of calling vm_direct_exit. This may cause a race condition with concurrent GC threads that are updating global objects and result in a crash.
Suggested fix:
- As a hack, we could call _exit(), which will quit the process without doing global cleanups
- But a more wholesome fix would be to avoid modifying the global states (such as vmClasses::_klasses) during -Xshare:dump. This should be fairly easy to implement.