RFR: 8207025: JvmtiEnv::SetSystemProperty() does not handle OOM [v4]

Ioi Lam iklam at openjdk.java.net
Tue Mar 29 15:41:29 UTC 2022


> `JvmtiEnv::SetSystemProperty` eventually calls `PathString::set_value` in arguments.cpp, which aborts the VM when it fails to allocate a string copy of the property value.
> 
> 
> bool PathString::set_value(const char *value) {
>   if (_value != NULL) {
>     FreeHeap(_value);
>   }
>   _value = AllocateHeap(strlen(value)+1, mtArguments   );
>   // should pass AllocFailStrategy::RETURN_NULL -----^
>   assert(_value != NULL, "Unable to allocate space for new path value");
> 
> 
> This should be fixed so that `JvmtiEnv::SetSystemProperty` can return `JVMTI_ERROR_OUT_OF_MEMORY` in case of OOM. See https://docs.oracle.com/en/java/javase/17/docs/specs/jvmti.html#SetSystemProperty

Ioi Lam has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:

 - Merge branch 'master' of https://github.com/openjdk/jdk into 8207025-simplify-pathstring-setvalue
 - @dholmes-ora comments: simplify the changes
 - @dholmes-ora comments: changed implementation to work with JvmtiEnv::SetSystemProperty
 - 8207025: Simplify PathString::set_value() in arguments.cpp

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/7981/files
  - new: https://git.openjdk.java.net/jdk/pull/7981/files/14a44f63..9fa4cc50

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=7981&range=03
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=7981&range=02-03

  Stats: 1781 lines in 82 files changed: 1348 ins; 78 del; 355 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7981.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7981/head:pull/7981

PR: https://git.openjdk.java.net/jdk/pull/7981


More information about the serviceability-dev mailing list