Problem with lua in 1.9

Posted by Orik on Fri 27 Mar 2009 01:52 AM — 6 posts, 29,150 views.

USA #0
I just added lua into 1.9 and get a crash on add_kill.

Tried killing Chadoyn and got this:

Program received signal SIGSEGV, Segmentation fault.
0x08253495 in luaS_newlstr ()
Current language:  auto; currently asm
(gdb) list
384     }  /* cleanup memory */
385
386     #ifdef WIN32
387     int mainthread( int argc, char **argv )
388     #else
389     int main( int argc, char **argv )
390     #endif
391     {
392        struct timeval now_time;
393        bool fCopyOver = FALSE;
(gdb) bt
#0  0x08253495 in luaS_newlstr ()
#1  0x0824af1e in lua_getfield ()
#2  0x0824036e in find_mud_lua_function (fname=0x829b491 "killed_mob") at lua_scripting.c:2719
#3  0x08244a27 in call_mud_lua_char_num (fname=0x829b491 "killed_mob", str=0x8603910 "George", num=10345)
    at lua_scripting.c:2787
#4  0x081773d5 in add_kill (ch=0x860b378, mob=0x8598c20) at handler.c:5111
#5  0x0816f80a in damage (ch=0x860b378, victim=0x8598c20, dam=18, dt=1003) at fight.c:2343
#6  0x08171a08 in one_hit (ch=0x860b378, victim=0x8598c20, dt=1003) at fight.c:1334
#7  0x081721b3 in multi_hit (ch=0x860b378, victim=0x8598c20, dt=-1) at fight.c:763
#8  0x08173971 in violence_update () at fight.c:387
#9  0x0822f43b in update_handler () at update.c:2095
#10 0x0813c496 in game_loop () at comm.c:879
#11 0x0813e4b0 in main (argc=2, argv=0xbfa3cac4) at comm.c:529
(gdb) frame 0
#0  0x08253495 in luaS_newlstr ()
(gdb) list
394     #ifdef IMC
395        int imcsocket = -1;
396     #endif
397
398        DONT_UPPER = FALSE;
399        num_descriptors = 0;
400        first_descriptor = NULL;
401        last_descriptor = NULL;
402        sysdata.NO_NAME_RESOLVING = TRUE;
403        sysdata.WAIT_FOR_AUTH = TRUE;
(gdb) frame 2
#2  0x0824036e in find_mud_lua_function (fname=0x829b491 "killed_mob") at lua_scripting.c:2719
2719      lua_getglobal (L_mud, fname);
Current language:  auto; currently c++
(gdb) print fname
$1 = 0x829b491 "killed_mob"


See anything in there?
Australia Forum Administrator #1
How did you add Lua, exactly?

It looks like it is crashing on looking up the function killed_mob in global script space. Next time, can you print L_mud? Maybe it is not set up for some reason. Or, it got corrupted.
USA #2
I just copied the files over and added it by finding everywhere it was done in 1.8.


(gdb) print L_mud
$1 = (lua_State *) 0x0
(gdb)


There's L_mud, guess nothing is being given to it.

Australia Forum Administrator #3
It is NULL, which means the Lua engine was never initialized. I would check the part of the code which does that.

Check where you have put the lines:


open_lua (ch);  /* fire up Lua state */


I would put a breakpoint there in gdb and see if that line is being called (probably not, I guess). If not, I would work out why not.
USA #4
I hadn't added:


   log_string( "Initializing Lua" );
   open_mud_lua ();  /* initialize Lua engine */


Right before the Booting Database in comm.c.


It's working now.
USA #5
Did you find it easy to get lua into 1.9