Integrated: 8207025: JvmtiEnv::SetSystemProperty() does not handle OOM

Ioi Lam iklam at openjdk.java.net
Tue Mar 29 21:24:48 UTC 2022


On Mon, 28 Mar 2022 04:14:32 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> `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

This pull request has now been integrated.

Changeset: 8cdabea0
Author:    Ioi Lam <iklam at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/8cdabea0abdc702242a3fb4b0538980ab8f6a9d6
Stats:     41 lines in 4 files changed: 17 ins; 9 del; 15 mod

8207025: JvmtiEnv::SetSystemProperty() does not handle OOM

Reviewed-by: dholmes, sspitsyn

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

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


More information about the hotspot-runtime-dev mailing list