gdb cores when stepping over fork() in 5.2-CURRENT.

From: Steve Young <sdyoung_at_vt220.org>
Date: Wed, 04 Feb 2004 23:37:23 -0700
	Hello all,

	I am running 5.2-CURRENT, freshly cvsup'ed this morning.  While 
working on a problem with syslogd (more on that later if it turns out 
to be real), I found that whenever a fork() call is stepped over in 
gdb, the child process dies with signal 5 (trace trap).  I'm not very 
familiar with gdb or how it sets breakpoints, so it's pure speculation 
but I wonder if perhaps it setting another breakpoint after the fork() 
call which is being caught in the parent process (which is attached to 
gdb), but the child process has nothing to handle it and so it dies 
with the default behavior, core dump.

	Anyway, here is the very simple sample program I am using to reproduce 
the problem.  Just set a break on main and 'n'ext through it and you 
will see that the child never gets to print its' message, and your 
syslog will note the child process dying with signal 5.

	Thanks,
	Steve.

/* forktest.c */
#include <stdio.h>

int main(int argc, char **argv) {
         int ret;
         printf("fork.\n");
         ret = fork();
         if(ret > 0) {
                 printf("\nParent got child pid, %d.\n", ret);
                 exit(0);
         } else if(ret < 0) {
                 perror("error");
                 exit(0);
         }

         printf("\nChild working too: %d\n", ret);
         exit(0);
}
Received on Wed Feb 04 2004 - 21:44:53 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:41 UTC