This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix Linux attach to signalled/stopped processes

On Wed, 27 Jun 2007 00:54:54 +0200, Mark Kettenis wrote:
> This is what I get on OpenBSD:
> $ ./ptrace-test                                                          
> .assertion "!WIFSIGNALED (status)" failed: file "ptrace-test.c", line 122, function "main"
> Abort trap (core dumped) 
> This is sort of odd,

Thanks for the test - it is now confirmed the code is not crossplatform and
different hacks may be needed on different ptrace(2)-using OSes.
OK, going to move it to linux-nat.c.

> but then your test program has a serious problem.
> It doesn't wait(2) after ptrace(PT_ATTACH, ...).  That's asking for trouble.

It does wait(2) right after a preventive `PT_CONT (SIGSTOP)' as otherwise
wait(2) would hang if the original process was already stopped ...

> > How does currently GDB behave there while attaching to a SIGSTOPped process?
> I don't think it matters whether the process is stopped or not.

... the same way the current GDB hangs.  SIGSTOP is already delivered before
and the new SIGSTOP from PTRACE_ATTACH does not stack as SIGSTOP is already
active.  If the original SIGSTOP was already wait(2)ed by the pre-ptrace(2)
parent the new ptrace(2)-parent (the debugger) will not get the new SIGSTOP
caught and thus wait(2) hangs for it.
[ Info originally from Roland McGrath. ]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]