This is the mail archive of the gdb@sources.redhat.com 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]

Re: gdb: detection and/or fork+gethostbyname crash workaround?


On Tue, Jul 24, 2001 at 08:52:19AM -0700, Kevin Buettner wrote:
> If it's one which uses ptrace(), the kernel usually prohibits two
> processes from invoking ptrace() on the same inferior.  So one
> strategy might be to have the program in question cause ptrace to be
> invoked on itself.  I don't think the process will be able to do this
> itself; I think it's likely that it would have to fork and let the
> child attempt this.  The return status from wait() or waitpid() could
> indicate whether the attempt to invoke ptrace() was successful or not.

That's what I tried (x86 Linux); a process can't ptrace itself.  I could
fork a process to test this, I suppose; I'll try that.  (Wouldn't it
be the return status from ptrace(), though?  I assume it'd return something
like EPERM if a process is already being debugged.)

> Of course, you should keep in mind that a race condition is possible.
> Just because you've determined at one point in your program that you
> aren't being debugged doesn't mean that this condition will hold
> later on.

That's OK.  The main problem is that every time I debug a process
(in this case, lftp), I have to manually disable DNS forking; I want
to prevent that.

> I searched gdb@sources.redhat.com w/ both of these search phrases and
> only came up with the message to which I'm responding.  Can you provide
> some URLs for the archived messages?

http://sources.redhat.com/ml/bug-glibc/2000-04/msg00018.html
http://sources.redhat.com/ml/bug-gdb/2001-03/msg00049.html

(the first is more useful; it was apparently CC'd to both
bug-glibc and bug-gdb, but that's what google turned up.)

Thanks.

-- 
Glenn Maynard


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