On Thu, 20 Jul 2023 06:53:26 GMT, Serguei Spitsyn <sspit...@openjdk.org> wrote:

> This problem is encountered when a JVMTI agent is loaded into running VM. The 
> JvmtiExport::get_jvmti_interface() is called from the agent's Agent_OnAttach 
> entrypoint. To support virtual threads it enables JVMTI notifications from 
> the VirtualThread class with a call to:
>   `JvmtiEnvBase::enable_virtual_threads_notify_jvmti()`.
> The problem is that there is no JVMTI environments at this point yet. This 
> assert is hit when a virtual thread is created concurrently after the JVMTI 
> notifications have been enabled but the requested JVMTI environment has not 
> been created yet.
> The fix is to create a JVMTI env first and only then to enable the JVMTI 
> notifications.
> 
> This issue is very hard to reproduce. I had to use some tricks with adding 
> `os::naked_short_nanosleep()` and also by refactoring the test 
> `VThreadTLSTest.java`. At least, I was able to verify this test does not fail 
> with my fix anymore.
> 
> Testing:
>  - submitted hundreds of `VThreadTLSTest.java` mach5 runs on several 
> platforms in the `fastdebug` mode
>  - in progress: mach5 tiers 1-6

This pull request has now been integrated.

Changeset: 783de32b
Author:    Serguei Spitsyn <sspit...@openjdk.org>
URL:       
https://git.openjdk.org/jdk/commit/783de32b6af4383b5ba71b91c307a5dddd0dae13
Stats:     26 lines in 2 files changed: 14 ins; 12 del; 0 mod

8300051: assert(JvmtiEnvBase::environments_might_exist()) failed: to enter 
event controller, JVM TI environments must exist

Reviewed-by: dholmes, pchilanomate

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

PR: https://git.openjdk.org/jdk/pull/14945

Reply via email to