RFR: 8290043: serviceability/attach/ConcAttachTest.java failed "guarantee(!CheckJNICalls) failed: Attached JNI thread exited without being detached"

Coleen Phillimore coleenp at openjdk.org
Wed Jan 8 21:08:48 UTC 2025


On Mon, 6 Jan 2025 09:33:31 GMT, David Holmes <dholmes at openjdk.org> wrote:

> This bug was introduced by [JDK-8252921](https://bugs.openjdk.org/browse/JDK-8252921) which moved the unregister call from the thread destructor (because it was not called for all threads) to the post_run() method. But this totally overlooked native threads that attach and detach! This is easily fixed by moving the unregister call to the end of JavaThread::exit.
> 
> We also update the ProblemList and disable -Xcheck:JNI for a test that does actually terminate threads without detaching.
> 
> Testing: tiers 1-4
> 
> Thanks.

src/hotspot/share/runtime/javaThread.cpp line 786:

> 784: 
> 785: // Shared teardown for all JavaThreads
> 786: void JavaThread::post_run() {

I think this would match nonJavaThread::post_run() better if you left this here, and put the NMT call in the detach code.  Ideally detach would call post_run(ExitType) rather than copying exit actions:

https://github.com/coleenp/jdk/blob/master/src/hotspot/share/prims/jni.cpp#L3941

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/22924#discussion_r1907865520


More information about the hotspot-runtime-dev mailing list