Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2006:
[Freeciv-Dev] (PR#16348) Lua crash
Home

[Freeciv-Dev] (PR#16348) Lua crash

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#16348) Lua crash
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sun, 9 Apr 2006 06:12:28 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=16348 >

The following seemingly correct script (almost identical to examples in
the wiki events documentation) will crash the server:

  function hut_enter_callback(unit)
    local settlers = find.unit_type('Settlers')

    if settlers then
      notify.event(owner, unit.tile, E.HUT_SETTLER,
                   _('LUA: Friendly nomads are impressed and join you.'))
      create_unit(unit.owner, unit.tile, settlers, 0, unit:homecity(), -1)
    end
    return false
  end

  signal.connect("hut_enter", "hut_enter_callback")

To reproduce, stuff this into /data/default/script.lua and find a hut.
This is the backtrace:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208759552 (LWP 4479)]
0x0812d076 in api_actions_create_unit (pplayer=0x0, ptile=0x0, ptype=0x0,
veteran_level=0,
    homecity=0x0, moves_left=-1) at api_actions.c:35
35        return create_unit(pplayer, ptile, ptype, veteran_level,
(gdb) bt
#0  0x0812d076 in api_actions_create_unit (pplayer=0x0, ptile=0x0, ptype=0x0, 
veteran_level=0,
    homecity=0x0, moves_left=-1) at api_actions.c:35
#1  0x0812bb81 in tolua_api_create_unit00 (tolua_S=0x8ce3520) at api_gen.c:1450
#2  0x0812f7da in luaD_precall (L=0x8ce3520, func=0x8d0b658) at ldo.c:260
#3  0x0813672b in luaV_execute (L=0x8ce3520) at lvm.c:627
#4  0x0812fc44 in luaD_call (L=0x8ce3520, func=0x8ca0e94, nResults=1) at 
ldo.c:313
#5  0x0812dfa2 in f_call (L=0x8ce3520, ud=0x0) at lapi.c:672
#6  0x0812f424 in luaD_rawrunprotected (L=0x8ce3520, f=0x812df8c <f_call>, 
ud=0xbfe51ac4)
    at ldo.c:88
#7  0x0812ff58 in luaD_pcall (L=0x8ce3520, func=0x812df8c <f_call>, 
u=0xbfe51ac4, old_top=0,
    ef=0) at ldo.c:416
#8  0x0812dff0 in lua_pcall (L=0x8ce3520, nargs=1, nresults=147895968, 
errfunc=8) at lapi.c:685
#9  0x08128aef in script_call (L=0x8ce3520, narg=1, nret=1) at script.c:127
#10 0x08128ca2 in script_callback_invoke (callback_name=0x8e45ea8 
"hut_enter_callback",
    nargs=1, args=0xbfe51ba0 "") at script.c:245
#11 0x08129055 in internal_signal_invoke_valist (signal_name=Variable 
"signal_name" is not available.) at script_signal.c:252
#12 0x081290a3 in script_signal_emit (signal_name=0x0, nargs=147895968) at 
script_signal.c:280
#13 0x08060f3a in move_unit (punit=0x93637e8, pdesttile=0xb7c4f890, move_cost=1)
    at unittools.c:2256

I am unsure how to debug this.

  - Per





[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#16348) Lua crash, Per I. Mathisen <=