-
Bug
-
Resolution: Fixed
-
P3
-
openjdk8u272, 11, 16
-
b05
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8262767 | 16.0.2 | Harold Seigel | P3 | Resolved | Fixed | b01 |
JDK-8262387 | 16.0.1 | Harold Seigel | P3 | Resolved | Fixed | b07 |
JDK-8286290 | 15.0.8 | Yuri Nesterenko | P3 | Resolved | Fixed | b02 |
JDK-8259802 | 11.0.11-oracle | Dukebot | P3 | Resolved | Fixed | b02 |
JDK-8260529 | 11.0.11 | David Holmes | P3 | Resolved | Fixed | b01 |
Hello,
I'm a contributor of the [jni-rs](https://github.com/jni-rs/jni-rs/) project. Rust bindings to the JNI.
When running tests against OpenJDK with the flag "-Xcheck:jni" enabled, we detected the following: the behaviour of the `JNI_COMMIT` mode of `ReleasePrimitiveArrayCritical` seems to be inconsistent, when running with `-Xcheck:jni` enabled, vs. without `-Xcheck:jni`.
If using "-Xcheck:jni" we're hitting a double free using `ReleasePrimitiveArrayCritical` with `JNI_COMMIT`, when we attempt to release the buffer at the end. It is our understanding that the behaviour of `ReleasePrimitiveArrayCritical` must be consistent, independently of whether the check JNI mode is enabled or not.
You can check [https://github.com/jni-rs/jni-rs/issues/283](https://github.com/jni-rs/jni-rs/issues/283) for details / comments on this.
We've tracked down the issue to this February 2019 commit: [openjdk commit 3e904a4](https://github.com/openjdk/jdk/commit/3e904a4801b2bf2e988ba096e5cb64a17fd5fce7). The related discussion is here: [openjdk bug
As there are no associated tests or functionality in the OpenJDK code base, I've simply reverted the commit. Just in case, I've also built and tested the JDK, without issues.
Not sure what tests are the ones mentioned in the discussions that led to the introduction of this behaviour. It is our understanding that tests of `JNI_COMMIT` functionality must still make a call to `ReleasePrimitiveArrayCritical` with a proper mode (`0` or `JNI_ABORT`) at the end, to release the buffer. And this, independently of `-Xcheck:jni` being enabled or not.
If there are any issues related to this that we're not aware of, please let us know.
- backported by
-
JDK-8259802 Using -Xcheck:jni can lead to a double-free after JDK-8193234
- Resolved
-
JDK-8260529 Using -Xcheck:jni can lead to a double-free after JDK-8193234
- Resolved
-
JDK-8262387 Using -Xcheck:jni can lead to a double-free after JDK-8193234
- Resolved
-
JDK-8262767 Using -Xcheck:jni can lead to a double-free after JDK-8193234
- Resolved
-
JDK-8286290 Using -Xcheck:jni can lead to a double-free after JDK-8193234
- Resolved
- relates to
-
JDK-8261089 [TESTBUG] native library of test TestCheckedReleaseCriticalArray.java fails to compile with gcc 4.x
- Resolved
-
JDK-8258185 [JNI] Clarify the specification in relation to portable use of APIs that involve the Primitive Array Release Modes
- Resolved
-
JDK-8259446 runtime/jni/checked/TestCheckedReleaseArrayElements.java fails with stderr not empty
- Resolved
-
JDK-8193234 When using -Xcheck:jni an internally allocated buffer can leak
- Resolved
- links to
-
Commit openjdk/jdk15u-dev/41642f12
-
Commit openjdk/jdk16u/b7b2f61b
-
Commit openjdk/jdk/712014c5
-
Review openjdk/jdk15u-dev/206
-
Review openjdk/jdk16u/43
-
Review openjdk/jdk/1816