Re: [GDB] [Debuging] Mud crashing on char loading.

From: Thomas Arp (
Date: 01/26/03

From: "Jason Ragsdale" <jrags@YAHOO.COM>
> Program received signal SIGSEGV, Segmentation fault.
> 0x080c8cf5 in save_char_vars (ch=0x84157d0) at
> dg_scripts.c:3127
> 3127      if (ch->script->global_vars == NULL) return;
> backtrace
> (gdb) bt
> #0  0x080c8cf5 in save_char_vars (ch=0x84157d0) at
> dg_scripts.c:3127
> #1  0x08086bea in save_char (ch=0x84157d0,
> load_room=-1) at db.c:2250

For the people unfamiliar with save_char_vars() here's the
relevant parts of the function:

  /* immediate return if no script (and therefore no variables) structure */
  /* has been created. this will happen when the player is logging in */
  if (SCRIPT(ch) == NULL) return;

  /* we should never be called for an NPC, but just in case... */
  if (IS_NPC(ch)) return;


  /* make sure this char has global variables to save */
  if (ch->script->global_vars == NULL) return;  << crashing line

  vars = ch->script->global_vars;

In other words, you have an invalid (but non-NULL) script pointer.
I'd suggest
print *ch      (with special attention on the component just
                before 'script')
print *ch->script (this will probably be garbage)

The most probable[1] reason for your crashes is adding some code
that writes one byte too far - overrun. Focus on the part of the
char_data structure immidiately before scripts; If you only
overrun with one byte, the script pointer is screwed.


[1] Since you haven't altered anything with scripts, and the code
    already checks for ch->script==NULL.

   | FAQ: |
   | Archives: |
   | Newbie List:   |

This archive was generated by hypermail 2b30 : 06/26/03 PDT