The cm03t001 test creates a local JNI handle in the prepare function. It later uses that handle from a callback function, from another thread. When the callback runs, ZGC applies a load barrier to that handle and self-heals it in the other threads stack. Later when that thread verifies its stack, during the start of its stack processing, it finds that the oop is unexpectedly not "bad".
It's invalid to send a local JNI handle over to another thread: https://docs.oracle.com/en/java/javase/15/docs/specs/jni/design.html#global-and-local-references So, my proposed fix is to convert the local handle to a global handle. I've tested this with the reproducer in the bug report. ------------- Commit messages: - 8254874: ZGC: JNIHandleBlock verification failure in stack watermark processing Changes: https://git.openjdk.java.net/jdk/pull/701/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=701&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8254874 Stats: 5 lines in 1 file changed: 5 ins; 0 del; 0 mod Patch: https://git.openjdk.java.net/jdk/pull/701.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/701/head:pull/701 PR: https://git.openjdk.java.net/jdk/pull/701