RFR: 8286331: jni_GetStringUTFChars() uses wrong heap allocator
Thomas Stuefe
stuefe at openjdk.java.net
Sun May 8 09:15:45 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.
Change looks good.
So, we accidentally call `NativeCallStack(int toSkip);` ? If yes, and we don't like that, should we declare that constructor as explicit?
-------------
Marked as reviewed by stuefe (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/8579
More information about the hotspot-runtime-dev
mailing list