[jdk8u-dev] Integrated: 8235211: serviceability/attach/RemovingUnixDomainSocketTest.java fails with AttachNotSupportedException: Unable to open socket file

Xin Liu xliu at openjdk.java.net
Mon May 9 16:42:00 UTC 2022


On Tue, 5 Apr 2022 00:55:22 GMT, Xin Liu <xliu at openjdk.org> wrote:

> Hi, 
> 
> Could you review this backport of 8235211? This is a follow up of JDK-8225690.
> 
> 
> This patch can't be applied to jdk8u cleanly. We replace os::naked_yield with os::yield(), which is available in jdk8u and have same implementations on Linux/BSD/AIX.  Except for that, all other changes are just path adjustment. 
> 
> There's a deadlock in the original backport. Both Signal dispatcher(refer to S for short) and AttachListener(A) are Java Threads.  Therefore, they are subject to safepoint synchronization.
> 
> A sets `_state` to AL_INITIALIZED and then get blocked at a safepoint(maybe AttachListener::dequeue).
> If the socket file is deleted and JVM receive SIGQUIT the, S realizes that the socket file has gone in `check_socket_file` and start to reinitialize it. It falls into this loop and prevent itself from reaching the safepoint.
> 
>      while (AttachListener::transit_state(AL_INITIALIZING,
>                                            AL_NOT_INITIALIZED) != AL_NOT_INITIALIZED) {
>         os::naked_yield();
>       }
> 
> 
> If A waked up and realized that the socket has gone,  it would set `_state` to AL_NOT_INITIALIZED. Current code is adeadlock.  A can’t wake up because S hasn’t reached the safepoint yet. S can’t reach the safepoint because A hasn’t set _state to AL_NOT_INITIALIZED.  This patch avoids the deadlock by trapping into blocked state before the loop.

This pull request has now been integrated.

Changeset: 1067c545
Author:    Xin Liu <xliu at openjdk.org>
Committer: Paul Hohensee <phh at openjdk.org>
URL:       https://git.openjdk.java.net/jdk8u-dev/commit/1067c545658ff0643ad625073f4fddc2f7a0daf0
Stats:     70 lines in 5 files changed: 37 ins; 2 del; 31 mod

8235211: serviceability/attach/RemovingUnixDomainSocketTest.java fails with AttachNotSupportedException: Unable to open socket file
8244973: serviceability/attach/RemovingUnixDomainSocketTest.java fails "stderr was not empty"

Reviewed-by: phh, andrew
Backport-of: 073e095e6053550b17b1daf33df2be4f4c4b40ad

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

PR: https://git.openjdk.java.net/jdk8u-dev/pull/32


More information about the jdk8u-dev mailing list