erh, something about DG.. :)

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


hi All

Lastest crash was tracked down to DG-Scripts:

#0  0x80c7e04 in find_else_end (trig=0x854cc98, cl=0x854c620,
go=0x854d1f8, sc=0x854cc20, type=0) at dg/dg_scripts.c:2130
2130      for (c = cl->next; c->next; c = c->next) {

Oki, wondering what that meant and tracking through the scripts I found a
script that seemed to be the sinner, format was like this, everything
behind # is a comment

----- Start script -----
if (<some statement>) # First IF
  if (<another statement>) # Second IF
    <DO SOMETHING>
  else # Belonging to Second IF
    <DO SOMETHING ELSE>
else # Really belonging to the First IF, but missing an END
  <DO SOMETHING ELSE>
----- End Script -----

So, this one crashed because there (from scripts p.o.v.) was 2 Else's
within the same if (Not good scripting, but still, DG should prevent the
mud from crashing when doing something like that.. :).

I've tried different things with various degrees of luck, So far my idea
was schematic:

Found if
  Look for else, elseif or end.

Now, if we at ANY POINT in that search hits that we have no more lines in
the script then stop execution and SCRIPT ERR that. So far, my solution to
the problem has been to do this in find_else_end (dg_scripts.c),

Here's a diff of my suggestion:


--- START SNIP ---
--- dg_scripts.c        Fri Feb 11 15:52:18 2000
+++ dg_scripts.c.new    Fri Feb 11 15:51:35 2000
@@ -2151,6 +2151,15 @@
     else if (!strn_cmp("end", p, 3))
       return c;

--- dg_scripts.c        Fri Feb 11 15:52:18 2000
+++ dg_scripts.c.new    Fri Feb 11 15:54:47 2000
@@ -2151,6 +2151,17 @@
     else if (!strn_cmp("end", p, 3))
       return c;

+/*
+** At this point we have checked everything for else, elseif or if
+** So, if there are no more lines, Builder has made a bad booboo
+** This should prevent a crash, I'm not sure if there is a better
+** way though
+*/
+    if (!c->next) {
+      sprintf(buf,"Script #%d have IF without END", GET_TRIG_VNUM(trig));
+      script_log(buf);
+      return c;
+    }
   }
--- END SNIP ---

If anyone has a better idea, I'd very much like to know.. :)

This one has been sent to Mark Heilpern as well :)

/S

"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