Re: [CODE] libc_free

From: Lubos Lunak (l.lunak@SH.CVUT.CZ)
Date: 06/16/98


George wrote:

> On Sat, 13 Jun 1998, Digital wrote:
>
> >I have a problem with red hat linux 4.2 and libc_free it gives me the
> >folling from gdb when I edit a new mob
> >
> >Wed Jun 10 14:59:24 :: OLC: Juno edits mob 21001
> >
> >Program received signal SIGSEGV, Segmentation fault.
> >0x4004249d in __libc_free ()
>
> Looks like you've been scribbling over some memory.
>
> Check strcpy's, sprintf's, and the like.
>
> Electric Fence or Checker will come in handy.

  It crashes after I edit a new mob using Oasis OLC ... already discussed few
times ago. All you have to do is to upgrade to bpl13 as was severaly
recommended, and if you want to know why .... I know only 2 things that can
cause free() to crash :
  1) You pass invalid argument to it - this is not your problem.
  2) You corrupt internal structures - I don't know exactly how Linux works
with its memory, but I think it's possibly somehow similar to MS-DOS's
MCBs ( Memory Control Blocks ), and these MCBs are placed exactly below the
allocated memory. So if you for example access -1-th element of an allocated
array, you corrupt its MCB or whatever it's called in Linux ( and Linux memory
managers usually don't care where are you writing :(  ).
  Exactly in your case, the MUD crashes in medit_save_internally(), where you
call free( mob_index ), or something like that. The places, where you   access
the -1-th element of mob_index, are in castle.c, if you are trying to assing a
specproc to a non-existing mob, and in shop.c, I think it's boot_shops(), if
you are trying to assing the shopkeeper() specproc to a non-existing
shopkeeper ( both these are fixed in bpl13 ). If you fix these two and the MUD
still crashes, use gdb, "break medit_save_internally", and step, step, step
.... , or use Electric Fence and protect the memory below ( "man libefence"
should help you, if EFence tells you "not enough memory"or something like
that, use mini-mud mode ).
  I don't know if the part about the memory management is correct, but, which
is important, you should be able to fix the bug with this.

 L.Lunak
 l.lunak@sh.cvut.cz

  I'd like to know in how many days will someone post next "It crashes after I
edit a new mob using Oasis OLC" ... maybe this bug could be mentioned in the
Oasic OLC documentation ( right next to that "flying monitor bug"  :)   ).


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



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