RFR: 8357601: Checked version of JNI Release<type>ArrayElements needs to filter out known wrapped arrays
Coleen Phillimore
coleenp at openjdk.org
Tue Jul 1 12:33:45 UTC 2025
On Mon, 26 May 2025 08:56:09 GMT, David Holmes <dholmes at openjdk.org> wrote:
> The checked version of `Get`/`Release<type>ArrayElements` uses `GuardedMemory` to perform error checking. When releasing the array the code needs to check for the known array tags from the other JNI APIs and report an error.
>
> We also expand `GuardedMemory` to allow for a second tag word so that we can discriminate additional allocation sites i.e. identifying use of `Get`/`SetPrimitiveArrayCritical`. And add further robustness to guard verification by using `SafeFetch`.
>
> Testing
> - new test
> - Tiers 1-4 (sanity)
Cool test. Looks fine. I had some earlier comments but nothing that would really improve the change.
src/hotspot/share/prims/jniCheck.cpp line 400:
> 398: if (orig_result == STRING_TAG || orig_result == STRING_UTF_TAG) {
> 399: bool was_utf = orig_result == STRING_UTF_TAG;
> 400: tty->print_cr("%s: called on something allocated by %s",
Can you use log_warning(memory) for this message rather than tty?
Maybe these should be tty since they're in jniCheck.
-------------
Marked as reviewed by coleenp (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/25444#pullrequestreview-2975217066
PR Review Comment: https://git.openjdk.org/jdk/pull/25444#discussion_r2177467112
More information about the hotspot-dev
mailing list