RFR: 8357601: Checked version of JNI Release<type>ArrayElements needs to filter out known wrapped arrays
David Holmes
dholmes at openjdk.org
Wed Jul 2 06:35:40 UTC 2025
On Tue, 1 Jul 2025 12:31:04 GMT, Coleen Phillimore <coleenp 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.
Thanks for the review @coleenp !
> 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.
`tty` is used throughout the jniCheck code.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/25444#issuecomment-3026627820
PR Review Comment: https://git.openjdk.org/jdk/pull/25444#discussion_r2179232621
More information about the hotspot-runtime-dev
mailing list