public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Xiao Yang <yangx.jy@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] recvmsg03: avoid close() and recvmsg() racing
Date: Wed, 14 Jun 2017 16:17:49 +0800	[thread overview]
Message-ID: <5940F12D.1000309@cn.fujitsu.com> (raw)
In-Reply-To: <b8b28551f48a4a849de1f39be9a480462aabe2ba.1497426579.git.jstancek@redhat.com>

Hi Jan,

Thanks for this fix, it looks good to me. :-)

Thanks,
Xiao Yang.
On 2017/06/14 15:52, Jan Stancek wrote:
> From: Sabrina Dubroca<sdubroca@redhat.com>
>
> This testcase rarely hangs on single CPU systems. Problem
> appears to be between recvmsg() and close():
> 1. sendmsg(), packet gets queued
> 2. close(), packet is dropped
> 3. recvmsg(), nothing to fetch
>
> strace of a buggy run:
>    [pid 17284] 16:04:41.042617 socket(AF_RDS, SOCK_SEQPACKET, 0) = 3
>    [pid 17284] 16:04:41.049549 close(3)    = 0
>    strace: Process 17290 attached
>    [pid 17284] 16:04:41.050765 socket(AF_RDS, SOCK_SEQPACKET, 0<unfinished ...>
>    [pid 17290] 16:04:41.050894 futex(0x7f95dfc57014, FUTEX_WAIT, 0, {tv_sec=10, tv_nsec=0}<unfinished ...>
>    [pid 17284] 16:04:41.051001<... socket resumed>  ) = 3
>    [pid 17284] 16:04:41.051111 bind(3, {sa_family=AF_INET, sin_port=htons(4000), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
>    [pid 17284] 16:04:41.051374 futex(0x7f95dfc57014, FUTEX_WAKE, 2147483647) = 1
>    [pid 17290] 16:04:41.051432<... futex resumed>  ) = 0
>    [pid 17284] 16:04:41.051442 recvmsg(3,<unfinished ...>
>    [pid 17290] 16:04:41.051455 socket(AF_RDS, SOCK_SEQPACKET, 0) = 3
>    [pid 17290] 16:04:41.051666 bind(3, {sa_family=AF_INET, sin_port=htons(4001), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
>    [pid 17290] 16:04:41.051724 sendmsg(3, {msg_name={sa_family=AF_INET, sin_port=htons(4000), sin_addr=inet_addr("127.0.0.1")}, msg_namelen=16, msg_iov=[{iov_base="hello world\0", iov_len=12}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 12
>    [pid 17290] 16:04:41.051975 close(3)    = 0
>    [pid 17290] 16:04:41.052492 +++ exited with 0 +++
>    [pid 17284] 16:04:41.052598<... recvmsg resumed>  {msg_namelen=32}, 0) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
>    [pid 17284] 16:04:41.052631 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=17290, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
>    [pid 17284] 16:04:41.052718 recvmsg(3, // hang
>
> Signed-off-by: Sabrina Dubroca<sdubroca@redhat.com>
> [ wrote changelog message ]
> Acked-by: Jan Stancek<jstancek@redhat.com>
> ---
>   testcases/kernel/syscalls/recvmsg/recvmsg03.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/testcases/kernel/syscalls/recvmsg/recvmsg03.c b/testcases/kernel/syscalls/recvmsg/recvmsg03.c
> index 31e7585b66ab..8bbdaceeb464 100644
> --- a/testcases/kernel/syscalls/recvmsg/recvmsg03.c
> +++ b/testcases/kernel/syscalls/recvmsg/recvmsg03.c
> @@ -90,6 +90,8 @@ static void client(void)
>   			"sendmsg() failed to send data to server");
>   	}
>
> +	TST_CHECKPOINT_WAIT(1);
> +
>   	SAFE_CLOSE(sock_fd1);
>   }
>
> @@ -137,6 +139,8 @@ static void server(void)
>   			msg.msg_namelen);
>   	}
>
> +	TST_CHECKPOINT_WAKE(1);
> +
>   	SAFE_CLOSE(sock_fd2);
>   }
>




  reply	other threads:[~2017-06-14  8:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-14  7:52 [LTP] [PATCH] recvmsg03: avoid close() and recvmsg() racing Jan Stancek
2017-06-14  8:17 ` Xiao Yang [this message]
2017-06-14 14:13 ` Cyril Hrubis
2017-06-14 14:54   ` Jan Stancek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5940F12D.1000309@cn.fujitsu.com \
    --to=yangx.jy@cn.fujitsu.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox