Subject: port-i386/10847: ptrace causes a Segmentation Fault when the target process is already being debugged or does not exist
To: None <gnats-bugs@gnats.netbsd.org>
From: None <trevin@eyring.com>
List: netbsd-bugs
Date: 08/16/2000 16:07:33
>Number:         10847
>Category:       port-i386
>Synopsis:       ptrace causes a Segmentation Fault when the target process is already being debugged or does not exist
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-i386-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 16 16:08:01 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Trevin Beattie
>Release:        NetBSD 1.4.2
>Organization:
Eyring Corporation
>Environment:
NetBSD tuktu.eyring.com 1.4.2 NetBSD 1.4.2 (TUKTU) #0: Thu Mar 23 09:25:10 MST 2000     root@tuktu.eyring.com:/usr/src/sys/arch/i386/compile/TUKTU i386 unknown

>Description:
When I run gdb and attempt to attach it to a process which is already
being debugged, I get "Segmentation fault (core dumped)".

I'm not sure if this is the same problem (or what the problem is), but
I also have another process which (I think) I set up to load a new
program image without starting it by calling ptrace(PT_TRACE_ME,
getpid(), 0, 0); and the parent process (after doing some housework)
should let it run by calling ptrace(PT_DETACH, child_pid, 0, 0);.
But what really happens is the child runs the new program and exits
before the parent is ready, and when the parent calls ptrace() it gets
a Segmentation Fault.
>How-To-Repeat:
% gdb <any program>
- Open another terminal or suspend gdb
% ps
- Note the pid of the program being debugged
% gdb <same program>
(gdb) attach <pid found above>
Attaching to program `<program>', process <pid>
Segmentation fault (core dumped)

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

% gdb <any program>
(gdb) attach <non-existent pid>
Attaching to program `<program>', process <pid>
Segmentation fault (core dumped)

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted: