bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fatal interaction of GDB, 'fork' and 'gethostbyname'


From: eric
Subject: Fatal interaction of GDB, 'fork' and 'gethostbyname'
Date: 22 Mar 2001 10:01:02 -0800

There appears to be a bug in GDB that interacts with 'fork' and 'gethostbyname'.

Basically, if I start an app under GDB and that app does a 'fork' and the child 
process then attempts to call 'gethostbyname', it croaks on a SIGTRAP.

Example:

int main ()
{
pid_t   PID;

PID = fork();
if (0 == PID)
{
// This call to 'sleep' is uncommented if I want to attach an instance of GDB
// to the child process.
// sleep( 20);

// This call to 'gethostbyname' will die a horrible death
// if the app is started under GDB.
struct hostent*  Data = gethostbyname( "myhost");
_exit( 0);
}
}

The problem does not occur if the app is *not* started under GDB.  
Interestingly enough, if I start the app from the command line and then attach 
an instance of GDB to the child process, the call to 'gethostbyname' works 
fine.  It is only when the app is started under GDB that it blows up.

I am encountering this problem using GDB 5.0 under RedHat Linux 7.0 (though 
I've seen reports of this same problem with other versions of GDB and Linux).

Eric Karlson
Senior Software Architect
Addamark Technologies

email: address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]