DG-Script's crashing..

From: The Merciless Lord of Everything (serces@mud.dk)
Date: 05/31/00


Hiya All

Finally, it seems I've nailed the problem down for crashing when editing
new rooms. (And this while I was looking for something else, funny eh? :)

It requires DG as first. Create a trigger that can be executed somewhat
controlled (a command trigger is nice):

-----
%echo% trigger is starting
wait 20s
%echo% trigger ended
-----

Now, Fire up the trigger and before the 20 seconds ends, edit a NEW room
(not one of the existing ones), wait for the crash (Or at least that is
what I've been able to deduce).

gdb shows:

Program received signal SIGSEGV, Segmentation fault.
0x80cc0c3 in script_driver (go=0x40161970, trig=0x85e44c0, type=2,
mode=1) at dg_scripts.c:2904
2904        if (!(sc = SCRIPT((struct room_data *) go))) {
(gdb) bt
#0  0x80cc0c3 in script_driver (go=0x40161970, trig=0x85e44c0, type=2,
mode=1) at dg_scripts.c:2904
#1  0x80c5fef in trig_wait_event (info=0x85e8380) at dg_scripts.c:489
#2  0x80c162d in process_events () at dg_event.c:80
#3  0x804a730 in heartbeat (pulse=1125) at comm.c:759
#4  0x804a6e9 in game_loop (mother_desc=6) at comm.c:742
#5  0x8049a89 in init_game (port=5000) at comm.c:296
#6  0x80499ee in main (argc=1, argv=0xbffffc74) at comm.c:263
#7  0x4005bcb3 in __libc_start_main (main=0x8049784 <main>, argc=1,
argv=0xbffffc74, init=0x8048fb8 <_init>, fini=0x80d2f64 <_fini>,
    rtld_fini=0x4000a350 <_dl_fini>, stack_end=0xbffffc6c) at
../sysdeps/generic/libc-start.c:78
(gdb) print *sc
Cannot access memory at address 0x0.
(gdb) print sc
$1 = (struct script_data *) 0x0
(gdb) print *trig
$2 = {nr = 201, attach_type = 2 '\002', data_type = 0 '\000', name =
0x85e4490 "new trigger", trigger_type = 64, cmdlist = 0x81bce48,
curr_state = 0x81bcea8,
  narg = 100, arglist = 0x0, depth = 1, loops = 0, wait_event = 0x0,
purged = 0 '\000', var_list = 0x85e4520, next = 0x0, next_in_world =
0x85e0088}
(gdb) print *go
Attempt to dereference a generic pointer.
(gdb) print go
$3 = (void *) 0x40161970
-----
(More information on request)

What I see as the problem is this:

Trigger starts and runs on the existing world. While rediting, the world
get's freed and everythign is reassigned (objs moved if needed and so on
:). Trigger reaches end of pause, and continues on a room that no longer
exist (It has been freed in the redit procedure), the result is a crash.

The code around where the crash occurs is:
File: dg_scripts.c
Function: int script_driver(void *go, trig_data *trig, int type, int mode)
      case WLD_TRIGGER:
        if (!(sc = SCRIPT((struct room_data *) go))) {
          sprintf(buf,"SYSERR:No room(%d)->script in script_driver",
                     ((struct room_data *) go)->number);
          mudlog(buf,DEB,LVL_IMMORT,TRUE);
          return FALSE;
        }
      break;

I'm going to dig deeper into this, but if anyone have the "Ah, that is
simply a matter of.." solution, I'd be more than happy to hear about it
:).

Friendly Greetings

Serces


"The Law of Self Sacrifice"
When you starve with a tiger, the tiger starves last.


     +------------------------------------------------------------+
     | 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