[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-serviceability-dev
Subject:    Integrated: 8281615: Deadlock caused by jdwp agent
From:       Zhengyu Gu <zgu () openjdk ! java ! net>
Date:       2022-02-23 3:07:52
Message-ID: rAORuiDtCKNgH5u75xHnyRRqYJkD5NdKqtu9hF4DfNI=.e485e675-8b7e-4fa7-8998-f08468c6aab9 () github ! com
[Download RAW message or body]

On Mon, 14 Feb 2022 14:27:45 GMT, Zhengyu Gu <zgu@openjdk.org> wrote:

> There are scenarios that JDWP agent can deadlock on `classTrackLock` monitor. \
> Following is the scenario in bug report. 
> **Java Thread** 
> -   loads a class and post `JVMTI_EVENT_CLASS_PREPARE` event
> - JDWP event callback handler calls `classTrack_processUnloads()` to handle the \
>                 event.
> - `classTrack_processUnloads()` takes `classTrackLock` lock, then tries to allocate \
>                 a new bag under the lock.
> - bag allocation code calls` jvmtiAllocate()`, which may be blocked by ongoing \
> safepoint due to state transition. 
> If the safepoint is GC safepoint (prior to JDK16) or `VM_JvmtiPostObjectFree`  \
> safepoint (JDK16 or later) 
> **VM Thread**
> - post `JVMTI_EVENT_OBJECT_FREE`
> - JDWP event callback handler calls `cbTrackingObjectFree()` to handle the event
> - `cbTrackingObjectFree()` tries to acquire `classTrackLock` lock, leads to \
> deadlock 
> From my research, there are three events that may be posted at safepoints, \
> `JVMTI_EVENT_GARBAGE_COLLECTION_START`, `JVMTI_EVENT_GARBAGE_COLLECTION_FINISH` and \
> `JVMTI_EVENT_OBJECT_FREE`, but only  `JVMTI_EVENT_OBJECT_FREE` is relevant to JDWP \
> agent. 
> The solution I purpose here, is simply move allocation/deallocation code outside of \
> `classTrackLock` lock. 
> 
> Test:
> - [x] tier1 
> - [x] vmTestbase_nsk_jdi
> - [x] vmTestbase_nsk_jdwp
> - [x] vmTestbase_nsk_jvmti

This pull request has now been integrated.

Changeset: e1060bee
Author:    Zhengyu Gu <zgu@openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/e1060bee2adb9f2e07ca09309d0f89132db30f28
                
Stats:     31 lines in 1 file changed: 18 ins; 5 del; 8 mod

8281615: Deadlock caused by jdwp agent

Reviewed-by: dholmes, cjplummer

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

PR: https://git.openjdk.java.net/jdk/pull/7461


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic