RFR: 8319244: implement JVMTI handshakes support for virtual threads [v4]

Patricio Chilano Mateo pchilanomate at openjdk.org
Thu Nov 16 19:05:30 UTC 2023


On Thu, 16 Nov 2023 17:22:35 GMT, Serguei Spitsyn <sspitsyn at openjdk.org> wrote:

>> Thanks! This is a valid concern. Will try to fix this.
>
> I'm suggesting to fix it this way for the unmounted case only:
> 
> @@ -1976,6 +1976,13 @@ JvmtiHandshake::execute(JvmtiUnitedHandshakeClosure* hs_cl, ThreadsListHandle* t
>        return;
>      }
>      if (target_jt == nullptr) {    // unmounted virtual thread
> +      // JvmtiVTMSTransitionDisabler can start after the vthread executed notifyJvmtiUnmount(), i.e.
> +      // the vthread is already outside the transition, but before changing the state to TERMINATED.
> +      // Changing the state to TERMINATED is racy, so we check if the continuation is done in advance.
> +      oop cont = java_lang_VirtualThread::continuation(target_h());
> +      if (jdk_internal_vm_Continuation::done(cont)) {
> +        return;
> +      }
>        hs_cl->do_vthread(target_h); // execute handshake closure callback on current thread directly
>      }
>    }

Sounds good. Is there a reason why not have the check inside JvmtiEnvBase::is_vthread_alive()?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16460#discussion_r1396202630


More information about the serviceability-dev mailing list