RFR: 8339769: VM crash during initialization if working directory does not exist [v2]

Justin Lu jlu at openjdk.org
Thu Sep 12 23:11:31 UTC 2024


> Please review this PR which restores the correct exception message when the current working directory can not be found during java startup in `initPhase1`.
> 
> Both MacOS and Linux are expected to fail with `java.lang.Error: Properties init: Could not determine current working directory` if the _user.dir_ system property cannot be initialized. Currently, MacOS now fails with `java.lang.InternalError: platform encoding not initialized` and Linux fails with  `java.lang.InternalError: null property: user.dir` which are both unexpected messages. 
> 
> In `System.c`, `Java_jdk_internal_util_SystemProps_00024Raw_platformProperties` calls `GetJavaProperties(JNIEnv *env)` which throws an internal error (with an appropriate message) for Unix platforms when the current working directory cannot be found. However, this exception is never checked and thus unexpected failures occur later. NULL should be returned after the exception is thrown, so that the initialization fails with the expected error when the return value is checked.
> 
> 
>     // Get the platform specific values
>     sprops = GetJavaProperties(env);
>     CHECK_NULL_RETURN(sprops, NULL);
> 
> 
> Testing done locally on both platforms.

Justin Lu has updated the pull request incrementally with one additional commit since the last revision:

  return null in exception site instead

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/20975/files
  - new: https://git.openjdk.org/jdk/pull/20975/files/ec2e3030..c69216ee

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=20975&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=20975&range=00-01

  Stats: 8 lines in 2 files changed: 3 ins; 1 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/20975.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20975/head:pull/20975

PR: https://git.openjdk.org/jdk/pull/20975


More information about the core-libs-dev mailing list