Re: [Circle] [Code] Poofin/out not saving.

From: Patrick Dughi (dughi@imaxx.net)
Date: 07/07/00


>
> After unsuccessfully trying all of the fixes from the ftp site, I decided to
> go through and have the poof's save the same way titles are done.
> The problem is that the system does a core dump once when attempting to save
> the poof's (regardless of if they had been modified from the default).
>
> Running a backtrace on GDB gives me the following.
> Core was generated by `circle'.
> Program terminated with signal 11, Segmentation fault.
> Reading symbols from /usr/lib/libcrypt.so.2...done.
> Reading symbols from /usr/lib/libc.so.4...done.
> Reading symbols from /usr/libexec/ld-elf.so.1...done.
> #0  0x80a32ac in write_aliases (ch=0x83f1e00) at alias.c:31
> 31        if (GET_ALIASES(ch) == NULL)
> (gdb) backtrace

        I think you're right, both the save and write_alias functions seem
correct - that means that somewhere, you have pointer mangling, and your
'GET_ALIASES(ch)' macro is attempting to reference garbage.

        I think I know why that might be.

        Looking at the player_special_data structure, I see that (in bpl17
at least) it looks something like this;

struct player_special_data {
   struct player_special_data_saved saved;

   char *poofin;                /* Description on arrival of a god.     */
   char *poofout;               /* Description upon a god's exit.       */
   struct alias_data *aliases;  /* Character's aliases                  */
   long last_tell;              /* idnum of last tell from              */
   void *last_olc_targ;         /* olc control                          */
   int last_olc_mode;           /* olc control                          */
};


        Now, I'm going to make a few assumptions, so don't jump up and
down if I get these wrong.

        I'm going to assume that you keep the same variable order.  That
is, poofin/poofout both come directly before the alias data, whether or
not they're in that same struct, or if you moved them to the bottom of the
player_special_data_saved structure (which seems to make more sense to
me).

        I'm also going to assume that you erased your player file after
modifying which elements save.

        Last, I'm going to assume that you have only a partial
understanding of pointers.  This last point is important, because I think
that you are probably saving or representing the poofin/out as char *'s
(like they are above) without allocating the correct space for them.  As a
result, when you load your poofin/out data into your character structure,
it overwrites your aliases with parts of your character strings.

        The solution for this is simple; mimic the way the title string
saves, and you should have no problem (just make sure that you don't
overwrite your bounds).

                        PjD


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



This archive was generated by hypermail 2b30 : 04/10/01 PDT