[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151119174754.GA13949@redhat.com>
Date: Thu, 19 Nov 2015 18:47:54 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Pedro Alves <palves@...hat.com>
Cc: Tejun Heo <tj@...nel.org>,
Jan Kratochvil <jan.kratochvil@...hat.com>,
Andrey Ryabinin <aryabinin@...tuozzo.com>,
Roland McGrath <roland@...k.frob.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: ptrace() hangs on attempt to seize/attach stopped & frozen task
Thanks Pedro for your email,
I'll recheck tomorrow, but at first glance:
On 11/19, Pedro Alves wrote:
>
> Both GDB and gdbserver have special processing for attaching to already-stopped
> processes.
Yes, I am starting to recall that I have looked at this code years ago ;)
> 907 linux_attach_lwp (ptid_t ptid)
> 908 {
> 909 struct lwp_info *new_lwp;
> 910 int lwpid = ptid_get_lwp (ptid);
> 911
> 912 if (ptrace (PTRACE_ATTACH, lwpid, (PTRACE_TYPE_ARG3) 0, (PTRACE_TYPE_ARG4) 0)
> 913 != 0)
> 914 return errno;
> 915
> 916 new_lwp = add_lwp (ptid);
> 917
> 918 /* We need to wait for SIGSTOP before being able to make the next
> 919 ptrace call on this LWP. */
> 920 new_lwp->must_set_ptrace_flags = 1;
> 921
> 922 if (linux_proc_pid_is_stopped (lwpid))
This can't happen today. Starting from v3.0 at least.
> This queuing of a SIGSTOP + PTRACE_CONT was necessary because
> otherwise when gdb attaches to a job stopped process, gdb would hang in the waitpid
> after PTRACE_ATTACH, waiting for the initial SIGSTOP which would never arrive.
Yes, because its exit code could be already cleared iirc. This was fixed
even before.
> If the proposed change makes it so that a new intermediate state can be observed
> right after PTRACE_ATTACH, and so linux_proc_pid_is_stopped can return false,
> then there's potential for breakage.
See above,
> But maybe not, if we're sure that
> that when that happens, waitpid returns for the initial
> PTRACE_ATTACH-induced SIGSTOP.
Yes. Just you can't assume that watpid(WNOHANG) will succeed. Is it OK?
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists