RFR: 8314225: SIGSEGV in JavaThread::is_lock_owned
Kevin Walls
kevinw at openjdk.org
Thu Jan 25 21:38:59 UTC 2024
On Thu, 25 Jan 2024 11:04:03 GMT, Kevin Walls <kevinw at openjdk.org> wrote:
> JavaThread's _monitor_chunks member is temporary storage used by deoptimization.
> When other threads inspect it using JavaThread::monitor_chunks(), if it is non-null that means a deoptimization is in progress, and the value will be removed shortly.
>
> There are a few places where we attempt to follow the MonitorChunk*, but that would only be valid if deopt is in progress, and only safe if we could know the deopt is not going to complete. But that the deopt will complete, and will free the MonitorChunks and clear the value. So this is rare but there is a race and a risk of following a MonitorChunk* as it gets freed, and crashing.
There are only a couple of callers to monitor_chunks() which are not deoptimization itself.
My current change for this is for the non-deopt users to call a new monitor_chunks_safe() method, which actually asserts that it is returning nullptr. If at a safepoint, it should be nullptr as deoptimization is not running. If not at a safepoint, it handshakes the target thread to retrieve the value. This lets deoptimization complete, and the value should be nullptr.
This change is to build confidence that _monitor_chunks is always null when observed outside of deoptimization. If that proves OK, the non-deopt related callers of monitor_chunks could be removed in future.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17566#issuecomment-1909937973
More information about the hotspot-dev
mailing list