The JVMTI function `SetEventNotificationMode` can set notification mode 
globally (`event_thread == nullptr`) for all threads or for a specific thread 
(`event_thread != nullptr`). To get a stable mount/unmount vision of virtual 
threads a JvmtiVTMSTransitionDisabler helper object is created :
    `JvmtiVTMSTransitionDisabler disabler(event_thread);`

In a case if `event_thread == nullptr` the VTMS transitions are disabled for 
all virtual thread,
otherwise they are disabled for a specific thread if it is virtual.
The call to `JvmtiEventController::set_user_enabled()` makes a call to 
`recompute_enabled()` at the end of its work to do a required bookkeeping. As 
part of this work, the `recompute_thread_enabled(state)` is called for each 
thread from the `ThreadsListHandle`, not only for the given specific 
`event_thread`.
This can cause crashes as VTMS transitions for other virtual threads are 
allowed.
Crashes are observed in this small function:

  bool is_interp_only_mode() {
    return _thread == nullptr ? _saved_interp_only_mode != 0 : 
_thread->is_interp_only_mode();
  }

In a case `_thread != nullptr` then the call needs to be executed: 
`_thread->is_interp_only_mode()`.
But the filed `_thread` can be already changed to `nullptr` by a VTMS 
transition.

The fix is to always disable all transitions.
Thanks to Dan and Patricio for great analysis of this crash!

Testing:
- In progress: mach5 tiers 1-6

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

Commit messages:
 - 8303086: SIGSEGV in JavaThread::is_interp_only_mode()

Changes: https://git.openjdk.org/jdk/pull/14728/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14728&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8303086
  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/14728.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/14728/head:pull/14728

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

Reply via email to