RFR: 8374343: Fix SIGSEGV when lib/modules is unreadable
David Holmes
dholmes at openjdk.org
Tue Jan 13 07:29:05 UTC 2026
On Wed, 24 Dec 2025 16:06:30 GMT, Boris Ulasevich <bulasevich at openjdk.org> wrote:
> The JVM crashes with a SIGSEGV during startup if the runtime image (lib/modules) exists but is unreadable. In this scenario, ClassLoader::get_jrt_entry() returns nullptr, leading to a crash. This change adds a null check to avoid the dereference and bail out gracefully.
Okay this seems to work in a reasonable way:
> chmod -r build/linux-x64-debug-null-modules/images/jdk/lib/modules
> ./build/linux-x64-debug-null-modules/images/jdk/bin/java -Xshare:off -version
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
> ./build/linux-x64-debug-null-modules/images/jdk/bin/java -Xshare:on -version
[0.017s][warning][class,path] Runtime image (modules) is unreadable or missing - validation failed
Error occurred during initialization of VM
Unable to use shared archive. Unrecoverable archive loading error (run with -Xlog:aot,cds for details): Unable to map shared spaces
> ./build/linux-x64-debug-null-modules/images/jdk/bin/java -Xshare:auto -version
[0.017s][warning][class,path] Runtime image (modules) is unreadable or missing - validation failed
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
I remain opposed in principle to trying to deal with parts of the JDK image not being accessible, but will approve this one case under the assumption/expectation this is as fas as it will go.
Thanks
-------------
Marked as reviewed by dholmes (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/28982#pullrequestreview-3654253959
More information about the hotspot-runtime-dev
mailing list