gdb cores when stepping over fork() in 5.2-CURRENT.
Steve Young
sdyoung at vt220.org
Wed Feb 4 22:44:53 PST 2004
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);
}
More information about the freebsd-current
mailing list