On Thu, 18 Nov 2021 09:34:13 GMT, Serguei Spitsyn <sspit...@openjdk.org> wrote:

>> The test fails when the target JavaThread has is_exiting() status. In such a 
>> case the JvmtiExport::cleanup_thread(this) has already made a clean up of 
>> its jvmtiThreadState, so the JavaThread address returned by 
>> _state->get_thread() is 0xbabababababababa.
>> The fix is to add a check for is_exiting() status into handshake closure 
>> do_thread() early.
>> There following handshake closures are fixed by this update:
>>   - UpdateForPopTopFrameClosure
>>  - SetForceEarlyReturn
>>  - SetFramePopClosure
>
> Serguei Spitsyn has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   get rid of the checks in jvmti handshakes: java_thread->threadObj() == NULL

src/hotspot/share/prims/jvmtiEnvBase.cpp line 1533:

> 1531:     return; /* JVMTI_ERROR_THREAD_NOT_ALIVE (default) */
> 1532:   }
> 1533:   assert(java_thread == _state->get_thread(), "Must be");

This `assert()` is the site of the original test failure. I haven't yet
looked at the locations of the other changes.

The `is_exiting()` check is made under the protection of the
`JvmtiThreadState_lock` so an unsuspended target thread that is
exiting cannot reach the point where the `_state` is updated to
clear the `JavaThread*` so we can't fail the `assert()` if the
`is_exiting()` check has returned `false`.

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

PR: https://git.openjdk.java.net/jdk/pull/6440

Reply via email to