> -Djdk.tracePinnedThreads is a debugging option that dates from early 
> development in the loom repo to identify pinned threads. It has several 
> issues and this tracing option will eventually be removed (use the JFR events 
> instead). Several hangs have been reported when running with the system 
> property set. The "hangs" stem from the onPinned callback executing while the 
> virtual thread is in a transition state (typically parking). If the virtual 
> parks while printing the stack trace then it works like a nested park where 
> the thread state is never restored. Contention on the System.out can also 
> lead to deadlock when there are platform and pinned virtual threads printing 
> to System.out around the same time.
> 
> This PR brings over the changes from the loom repo to avoid these hangs. The 
> changes mean the stack trace is only printed to System.out when the 
> PrintStream lock can be acquired without blocking. It also restores the 
> thread state after printing. An alternative to not printing traces would of 
> course be to queue the traces so they are printed by another thread but this 
> is just adding complexity for a debugging option that we want to go away.

Alan Bateman has updated the pull request with a new target base due to a merge 
or a rebase. The incremental webrev excludes the unrelated changes brought in 
by the merge/rebase. The pull request contains three additional commits since 
the last revision:

 - Expand TracePinnedThreads.testContention test description
 - Merge
 - Initial commit

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/17221/files
  - new: https://git.openjdk.org/jdk/pull/17221/files/15993866..ab8a2bcb

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=17221&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=17221&range=00-01

  Stats: 2985 lines in 239 files changed: 1868 ins; 364 del; 753 mod
  Patch: https://git.openjdk.org/jdk/pull/17221.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/17221/head:pull/17221

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

Reply via email to