Re: Segfault in memcpy() .. help... :)

From: Michael J. Cunningham (malice@epix.net)
Date: 04/10/96


On Thu, 11 Apr 1996, Rasmus Rxnlev wrote:

> Core was generated by `bin/ConMUD.exe 5000'.
> Program terminated with signal 11, Segmentation fault.
> Reading symbols from /usr/lib/libsocket.so.1...done.
> Reading symbols from /usr/lib/libnsl.so.1...done.
> Reading symbols from /usr/lib/libc.so.1...done.
> Reading symbols from /usr/lib/libdl.so.1...done.
> Reading symbols from /usr/lib/libintl.so.1...done.
> Reading symbols from /usr/lib/libmp.so.1...done.
> Reading symbols from /usr/lib/libw.so.1...done.
> Reading symbols from /usr/lib/nss_nisplus.so.1...done.
> Reading symbols from /usr/lib/nss_dns.so.1...done.
> Reading symbols from /usr/lib/libresolv.so.1...done.
> #0  0xdf66231c in _memcpy ()
> 
> (gdb) back       This is the same output as with the where cmd.
> 
> #0  0xdf66231c in _memcpy ()
> #1  0xdf69e6a8 in _doprnt ()
> #2  0xdf6ab16c in sprintf ()
> #3  0xa9244 in write_aliases (ch=0x8f69c8) at alias.c:35
> #4  0x3f150 in do_save (ch=0x8f69c8, argument=0xdffff84b "", cmd=254, 
> subcmd=0)
>     at act.other.c:105
> #5  0x78308 in command_interpreter (ch=0x8f69c8, argument=0xdffff848 "sav")
>     at interpreter.c:721
> #6  0x1b17c in game_loop (mother_desc=3) at comm.c:514
> #7  0x1a504 in init_game (port=5000) at comm.c:223
> #8  0x1a458 in main (argc=2, argv=0xdffffe5c) at comm.c:192

Without being able to determine the exact line in your program that
it died..you didnt list it, I would say that you are trying to 
sprintf a null pointer into a buffer. This is proably the cause of
the _memcpy problem. Put a check in before the sprintf to make sure
that the variable is not null before trying to copy it to the buffer.

d.
--
|\      /|
| \    / |
|  \  /  |
|   \/   |
|        |
|        | alice@epix.net
           Enough Said...



This archive was generated by hypermail 2b30 : 12/18/00 PST