public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "周春明(日月)" <riyue.zcm@alibaba-inc.com>
To: "Simon Marchi" <simon.marchi@polymtl.ca>,
	"Gdb-patches"
	<gdb-patches-bounces+riyue.zcm=alibaba-inc.com@sourceware.org>,
	 "gdb-patches" <gdb-patches@sourceware.org>
Subject: Re:Re:GDB often is blocked at async_file_flush
Date: Mon, 05 Jul 2021 13:30:59 +0800	[thread overview]
Message-ID: <8b123c96-0b48-4624-9ab8-c588bc802f94.riyue.zcm@alibaba-inc.com> (raw)



------------------------------------------------------------------
发件人:Simon Marchi <simon.marchi@polymtl.ca>
发送时间:2021年7月5日(星期一) 08:53
收件人:周春明(日月) <riyue.zcm@alibaba-inc.com>; Gdb-patches <gdb-patches-bounces+riyue.zcm=alibaba-inc.com@sourceware.org>; gdb-patches <gdb-patches@sourceware.org>
主 题:Re: Re:GDB often is blocked at async_file_flush

On 2021-07-04 8:13 p.m., 周春明(日月) wrote:
> Hi Simon,
> Thanks for reply.
> and yes, gdb is stuck in this loop:
>   do
>     {
>       ret = read (linux_nat_event_pipe[0], &buf, 1);
>     }
>   while (ret >= 0 || (ret == -1 && errno == EINTR));
> 
> The ret from read is always 0 when stuck happens. With my further debug in kernel pipe_read, this situation happens when pipe->writers is NULL.
> Because this is random issue, I compared with normal execution, the pipe->writers is not NULL and pipe->wait_writers is null, pipe_read will return -EAGAIN, then above loop exit normally.
> So do you know when pipe->writers would be NULL? sub-process is suspended?

Hmm, does that mean that the writer end of the pipe would be closed, but
not the read end?  I don't see how that can happen, as they are both
closed as a pair in linux_async_pipe, when enable is 0.

I tried the following test program, and indeed read returns 0:

    #include <unistd.h>
    #include <stdio.h>
    #include <fcntl.h>

    int main ()
    {
      int fds[2];
      pipe(fds);
      fcntl(fds[0], F_SETFL, O_NONBLOCK);
      fcntl(fds[1], F_SETFL, O_NONBLOCK);
      close(fds[1]);

      char c;
      int ret = read (fds[0], &c, 1);
      if (ret < 0)
 perror("read");

      printf("ret = %d\n", ret);
    }

When you have that infinite loop, what is the value of the two elements
of linux_nat_event_pipe?
[David] I tried this, when infinit loop happens, two elements of linux_nat_event_pipe are "
*****pipe[1]:12, pipe[0]:11",  do you know any other case will result in pipe[0]-read returns 0 except closing pipe[1]?
If you could share a reproducer for how to get to this state, it would
be useful.
[David] The project is our custom project for our asic, which isn't public yet. I also tried narrow down special case to reproduce it in common GDB, but failed.

-David 

Simon


             reply	other threads:[~2021-07-05  5:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-05  5:30 周春明(日月) [this message]
2021-07-05 12:25 周春明(日月)
2021-07-05 12:38 ` Pedro Alves

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=8b123c96-0b48-4624-9ab8-c588bc802f94.riyue.zcm@alibaba-inc.com \
    --to=riyue.zcm@alibaba-inc.com \
    --cc=gdb-patches-bounces+riyue.zcm=alibaba-inc.com@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).