Re: [Code] [Hedit] Problem saving helps

From: Lubos Lunak (
Date: 12/01/98

Dne Út, 01 prosinec 1998 jste napsal(a):
>I am running into a problem with hedit (and I have gone back over the code
>in the patch by hand and fixed any "obvious" problems).
>Everything compiles without too many errors (none in the hedit/olc part of
>the code) (Oasis 1.6b, Circle 3.14, many other mods).
>I am terribly clueless when it comes to gdb, so figuring out a crash that
>doesn't give me an error message is difficult.
>This is where the crash almost has to happen:
>>    switch (*arg) {
>>    case 'y':
>>    case 'Y':
>>      hedit_save_internally(d);
>>      sprintf(buf, "OLC: %s edits help for %s.", GET_NAME(d->character),
>>              OLC_HELP(d)->keywords);
>>      mudlog(buf, CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)),
>>             TRUE);
>>      cleanup_olc(d, CLEANUP_STRUCTS);
>>      send_to_char("Help entry saved to memory.\r\n", d->character);
>>      break;
>Because I get the "Do you wish to save this help entry internally?" but
>never see "Help entry saved to memory" (instead I get a crash).
>Are there any obvious problems with the above code?  Here is
>>void hedit_save_internally(struct descriptor_data *d)
>>  int i, rnum;
>>  struct help_index_element *new_help_table;
>>  rnum = OLC_ZNUM(d);
>>  if (rnum > 0) {
>>    free_help(help_table + rnum);
>>    help_table[rnum] = *OLC_HELP(d);
>>  } else {
>>    CREATE(new_help_table, struct help_index_element, top_of_helpt + 2);
>>    new_help_table[0] = *(OLC_HELP(d));
>>    for (i = 0; i <= top_of_helpt; i++)
>>      new_help_table[i + 1] = help_table[i];
>>    free(help_table);
>>    help_table = new_help_table;
>>    top_of_helpt++;
>>  }
>>  olc_add_to_save_list(HEDIT_PERMISSION, OLC_SAVE_HELP);
>Any hints would be greatly appreciated...   hedit isn't much use without
>being able to save  :)

Hmm, looks like the medit crash bug, but I'm not sure. If it crashes only when
you save new help entries, not already existing ones, and it crashes on
the line 'free(help_table)' ( core doesn't help here, you have to step step
step ... ), it's probably what I think it is.
You are somewhere accessing help_table[ -1 ] element. Use ElectricFence or
something like that and protect below ( EF_PROTECT_BELOW ). Try 'man efence'
if you don't know how to use ElectricFence.
If it's not the bug I think it is ...


Sorry if this message is repeated, I have a little problem with mailserver :(

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

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