-
Bug
-
Resolution: Fixed
-
P4
-
17, 20, 21
-
b26
-
Not verified
When calling `JNU_GetStringPlatformChars` with UTF8 strings, the `getStringUTF8` function retrieves the internal String value array and copies its contents using `GetPrimitiveArrayCritical` and `ReleasePrimitiveArrayCritical`.
Upon releasing the memory, the JNI_ABORT flag is not specified. If `GetPrimitiveArrayCritical` returns a copy of the array, then the call to `ReleasePrimitiveArrayCritical` copies the contents back.
Strings in Java are considered immutable, and I think their memory should never be written to (even if the contents aren't changed). In GraalVM they may be stored in a read-only memory section making this behaviour cause a segfault. Using `JNI_ABORT` also improves the performance of the application when a copy is returned.
I will submit a patch to add the JNI_ABORT flag to both calls of `ReleasePrimitiveArrayCritical`.
Upon releasing the memory, the JNI_ABORT flag is not specified. If `GetPrimitiveArrayCritical` returns a copy of the array, then the call to `ReleasePrimitiveArrayCritical` copies the contents back.
Strings in Java are considered immutable, and I think their memory should never be written to (even if the contents aren't changed). In GraalVM they may be stored in a read-only memory section making this behaviour cause a segfault. Using `JNI_ABORT` also improves the performance of the application when a copy is returned.
I will submit a patch to add the JNI_ABORT flag to both calls of `ReleasePrimitiveArrayCritical`.