Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 04 Feb 2004 23:37:23 -0700
From:      Steve Young <sdyoung@vt220.org>
To:        freebsd-current@freebsd.org
Subject:   gdb cores when stepping over fork() in 5.2-CURRENT.
Message-ID:  <C1AE09C1-57A5-11D8-BE05-0003939C3B2E@vt220.org>

next in thread | raw e-mail | index | archive | help

	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);
}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C1AE09C1-57A5-11D8-BE05-0003939C3B2E>