Re: [Question] Segmentation fault

From: Peter Ajamian (peter@pajamian.dhs.org)
Date: 04/16/01


In an earlier post Dust wrote:
> #2  0x8049929 in main (argc=3, argv=0xbfbffbec) at comm.c:304

Later Dust wrote:
>
>     } else if ((port = atoi(argv[pos])) <= 1024) {         <-- 302 usually
> the error

Hrmmm, strange, I can see the possibility of a seg fault at 302 if argv
is indexed wrong, try this (in gdb) on a core dump that crashes on 302.
Let me know the results:

(gdb) frame 2
(gdb) list
(gdb) print argc
(gdb) print pos
(gdb) print argv[pos]

>       exit(1);                        <- 304 sometimes the error

This is really strange.  Unless The compiler/platform you're using
doesn't like exit(1) and really needs to have exit(EXIT_FAILURE) (which I
highly doubt, but if it _is_ the case boy will I be gloating *pokes some
people on the list*), The only thing I can possibly think of that could
be causing the crash here is if the function pointer for exit() got
messed up by a buffer overrun which really happened earlier.  The way to
check this is two-fold.  First print the value of exit after the crash (I
think this will show the function pointer, but not positive).  If this is
0x0 you can stop, that's most definately the problem, otherwise you'll
need to restart the MUD in GDB with a breakpoint set to main and print
the exit pointer right at the MUD startup to compare the two.  The
following lines in gdb should take care of that (show us the output)...

(gdb) frame 2
(gdb) print exit
(gdb) break main
(gdb) run
(gdb) print exit
(gdb) quit

Answer yes when it asks if you want to terminate a running program.

Regards, Peter

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST