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

David Holmes dholmes at openjdk.org
Thu Jul 20 07:30:42 UTC 2023


On Thu, 20 Jul 2023 06:53:26 GMT, Serguei Spitsyn <sspitsyn at 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 seems a reasonable solution.

Thanks.

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

Marked as reviewed by dholmes (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/14945#pullrequestreview-1538610965


More information about the serviceability-dev mailing list