Integrated: 8286331: jni_GetStringUTFChars() uses wrong heap allocator

Zhengyu Gu zgu at openjdk.java.net
Mon May 9 19:48:57 UTC 2022


On Fri, 6 May 2022 17:54:45 GMT, Zhengyu Gu <zgu at openjdk.org> wrote:

> jni_GetStringUTFChars()  calls `AllocateHeap(length + 1, mtInternal, 0, AllocFailStrategy::RETURN_NULL);` to allocate memory, where it passes `0` as `NativeCallStack` reference, that results construction of `NativeCallStack`.
> 
> In `NativeCallStack`'s constructor, it performs stack walk to capture native call stack. This is unnecessary, if NMT detail tracking is not enabled.
> 
> It should use `char* AllocateHeap(size_t size,
>                    MEMFLAGS flags,
>                    AllocFailType alloc_failmode /* = AllocFailStrategy::EXIT_OOM*/)` heap allocator instead.

This pull request has now been integrated.

Changeset: b0d2b0a3
Author:    Zhengyu Gu <zgu at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/b0d2b0a3553cbb2db23d543b98ab1401b3dbfa91
Stats:     3 lines in 2 files changed: 0 ins; 0 del; 3 mod

8286331: jni_GetStringUTFChars() uses wrong heap allocator

Reviewed-by: dlong, stuefe

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

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


More information about the hotspot-runtime-dev mailing list