RFR: 8260341: CDS dump VM init code does not check exceptions
Ioi Lam
iklam at openjdk.java.net
Wed Feb 10 05:17:51 UTC 2021
When CDS dumping is enabled, special initialization happens during VM init. However, many of these calls do not properly check for exception. Instead, they rely on the implicit knowledge that `metaspace::allocate()` will exit the VM when allocation fails during CDS dumping. This makes the code hard to understand and tightly coupled to `metaspace::allocate()`.
The fix is: all code that makes allocation should be using CHECK macros, so each block of code can be individually understood without considering the behavior of `metaspace::allocate()`.
I added `TRAPS` to a bunch of CDS-related functions that are called during VM init. In some cases, I changed `Thread* THREAD` to `TRAPS`. This also eliminated a few `Thread* THREAD = Thread::current()` calls.
The "root" of these calls, such as `MetaspaceShared::prepare_for_dumping()`, now follows this pattern:
EXCEPTION_MARK;
ClassLoader::initialize_shared_path(THREAD);
if (HAS_PENDING_EXCEPTION) {
java_lang_Throwable::print(PENDING_EXCEPTION, tty);
vm_exit_during_initialization("ClassLoader::initialize_shared_path() failed unexpectedly");
}
-------------
Commit messages:
- 8260341: CDS dump VM init code does not check exceptions
Changes: https://git.openjdk.java.net/jdk/pull/2494/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2494&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8260341
Stats: 97 lines in 12 files changed: 18 ins; 11 del; 68 mod
Patch: https://git.openjdk.java.net/jdk/pull/2494.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/2494/head:pull/2494
PR: https://git.openjdk.java.net/jdk/pull/2494
More information about the hotspot-dev
mailing list