RFR: 8285794: AsyncGetCallTrace might acquire a lock via JavaThread::thread_from_jni_environment
David Holmes
dholmes at openjdk.java.net
Thu Apr 28 11:26:02 UTC 2022
On Thu, 28 Apr 2022 11:15:34 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> Calling JavaThread::thread_from_jni_environment for a terminated thread in AsyncGetCallTrace might cause the acquisition of a lock, making AsyncGetCallTrace non-signal-safe.
>>
>> AsyncGetCallTrace can only be called for the current threads (there are asserts for that), therefore using JavaThread::current directly and checking the termination status is semantically equivalent.
>
> src/hotspot/share/prims/forte.cpp line 566:
>
>> 564: void AsyncGetCallTrace(ASGCT_CallTrace *trace, jint depth, void* ucontext) {
>> 565:
>> 566: JavaThread* thread = JavaThread::current_or_null();
>
> As this can be in a signal handling context it needs to be Thread::current_or_null_safe().
Also please add a comment before this:
// Can't use thread_from_jni_environment as it may also perform a VM exit check that is unsafe to
// do from this context.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8446
More information about the hotspot-dev
mailing list