Page 1 of 2
Game crashes on startup
Posted: Thu May 13, 2010 3:26 pm
by Nerdanel
When I try to start the game, I get the following error:
Code: Select all
PANIC: unprotected error in call to Lua API (Unable to initialize: luaL_loadbuffer() failed)
The game was compiled from source on 64-bit Linux. I've tried moving the t-engine binary (it started in bin/Debug) around in case this was a path problem, but nothing has worked thus far.
Re: Game crashes on startup
Posted: Thu May 13, 2010 5:07 pm
by Nerdanel
Do we know if this is a 64-bit bug or not? The size_t variable "size" in luaL_loadbuffer is suspicious but I don't know if it's at fault. Has anyone else managed to get the game run on 64-bit Linux?
Re: Game crashes on startup
Posted: Thu May 13, 2010 5:21 pm
by darkgod
I do not have a 64 OS sadly :/
But IIRC madmonk is on 64bits linux no ?
Re: Game crashes on startup
Posted: Thu May 13, 2010 6:05 pm
by madmonk
32 bit, I am sorry!
Re: Game crashes on startup
Posted: Thu May 13, 2010 6:31 pm
by Shoob
thats what I thought, I know bigfoot uses a 64bit, but he is windows not linux
Re: Game crashes on startup
Posted: Thu May 13, 2010 7:46 pm
by Nerdanel
For your information, I got you the list of compile warnings from the T-Engine:
Code: Select all
==== Building TEngine ====
Creating obj/Debug/TEngine
map.c
src/map.c: In function 'luaopen_map':
src/map.c:409: warning: passing argument 3 of 'auxiliar_newclass' discards qualifiers from pointer target type
src/auxiliar.h:38: note: expected 'struct luaL_Reg *' but argument is of type 'const struct luaL_Reg *'
music.c
src/music.c: In function 'music_new':
src/music.c:39: warning: initialization makes pointer from integer without a cast
src/music.c: In function 'music_play':
src/music.c:64: warning: format '%x' expects type 'unsigned int', but argument 2 has type 'struct Mix_Music *'
src/music.c: In function 'sound_new':
src/music.c:94: warning: initialization makes pointer from integer without a cast
src/music.c: In function 'luaopen_sound':
src/music.c:174: warning: passing argument 3 of 'auxiliar_newclass' discards qualifiers from pointer target type
src/auxiliar.h:38: note: expected 'struct luaL_Reg *' but argument is of type 'const struct luaL_Reg *'
src/music.c:175: warning: passing argument 3 of 'auxiliar_newclass' discards qualifiers from pointer target type
src/auxiliar.h:38: note: expected 'struct luaL_Reg *' but argument is of type 'const struct luaL_Reg *'
struct.c
display_sdl.c
core_lua.c
src/core_lua.c: In function 'lua_distance':
src/core_lua.c:240: warning: incompatible implicit declaration of built-in function 'sqrt'
src/core_lua.c: In function 'sdl_new_font':
src/core_lua.c:415: warning: passing argument 1 of 'TTF_OpenFontRW' makes pointer from integer without a cast
/usr/include/SDL/SDL_ttf.h:91: note: expected 'struct SDL_RWops *' but argument is of type 'int'
src/core_lua.c: In function 'sdl_load_image':
src/core_lua.c:601: warning: assignment makes pointer from integer without a cast
src/core_lua.c: In function 'lua_file_write':
src/core_lua.c:1364: warning: passing argument 3 of 'lua_tolstring' from incompatible pointer type
src/lua/lua.h:149: note: expected 'size_t *' but argument is of type 'int *'
src/core_lua.c: In function 'lua_zip_add':
src/core_lua.c:1416: warning: passing argument 3 of 'lua_tolstring' from incompatible pointer type
src/lua/lua.h:149: note: expected 'size_t *' but argument is of type 'int *'
src/core_lua.c: In function 'luaopen_core':
src/core_lua.c:1577: warning: passing argument 3 of 'auxiliar_newclass' discards qualifiers from pointer target type
src/auxiliar.h:38: note: expected 'struct luaL_Reg *' but argument is of type 'const struct luaL_Reg *'
src/core_lua.c:1578: warning: passing argument 3 of 'auxiliar_newclass' discards qualifiers from pointer target type
src/auxiliar.h:38: note: expected 'struct luaL_Reg *' but argument is of type 'const struct luaL_Reg *'
src/core_lua.c:1579: warning: passing argument 3 of 'auxiliar_newclass' discards qualifiers from pointer target type
src/auxiliar.h:38: note: expected 'struct luaL_Reg *' but argument is of type 'const struct luaL_Reg *'
src/core_lua.c:1580: warning: passing argument 3 of 'auxiliar_newclass' discards qualifiers from pointer target type
src/auxiliar.h:38: note: expected 'struct luaL_Reg *' but argument is of type 'const struct luaL_Reg *'
src/core_lua.c:1581: warning: passing argument 3 of 'auxiliar_newclass' discards qualifiers from pointer target type
src/auxiliar.h:38: note: expected 'struct luaL_Reg *' but argument is of type 'const struct luaL_Reg *'
src/core_lua.c:1582: warning: passing argument 3 of 'auxiliar_newclass' discards qualifiers from pointer target type
src/auxiliar.h:38: note: expected 'struct luaL_Reg *' but argument is of type 'const struct luaL_Reg *'
src/core_lua.c:1583: warning: passing argument 3 of 'auxiliar_newclass' discards qualifiers from pointer target type
src/auxiliar.h:38: note: expected 'struct luaL_Reg *' but argument is of type 'const struct luaL_Reg *'
src/core_lua.c:1584: warning: passing argument 3 of 'auxiliar_newclass' discards qualifiers from pointer target type
src/auxiliar.h:38: note: expected 'struct luaL_Reg *' but argument is of type 'const struct luaL_Reg *'
getself.c
src/getself.c: In function 'get_self_executable':
src/getself.c:32: warning: function returns address of local variable
particles.c
src/particles.c: In function 'luaopen_particles':
src/particles.c:333: warning: passing argument 3 of 'auxiliar_newclass' discards qualifiers from pointer target type
src/auxiliar.h:38: note: expected 'struct luaL_Reg *' but argument is of type 'const struct luaL_Reg *'
auxiliar.c
main.c
src/main.c: In function 'display_utime':
src/main.c:82: warning: format '%d' expects type 'int', but argument 5 has type '__suseconds_t'
src/main.c: In function 'main':
src/main.c:468: warning: passing argument 1 of 'SDL_WM_SetIcon' makes pointer from integer without a cast
/usr/include/SDL/SDL_video.h:897: note: expected 'struct SDL_Surface *' but argument is of type 'int'
SFMT.c
Linking TEngine
bin/Debug/liblua.a(loslib.o): In function `os_tmpname':
/home/maija/t-engine4/src/lua/loslib.c:60: warning: the use of `tmpnam' is dangerous, better use `mkstemp'
Nothing in particular jumps out. I fixed the two trivial size_t warnings, but as expected, nothing changed.
Are we even sure this is a 64-bit Linux bug? From where are people running their executable? Does the executable give that particular message if it can't find the parts of the game compiled as separate libraries, like liblua.a? Notably, I got the same error regardless of where I put the executable. Are the libraries supposed to be under bin/Debug and does it matter if I install under my home directory (like I did) or system-wide?
Re: Game crashes on startup
Posted: Thu May 13, 2010 7:59 pm
by Nerdanel
Hmmmm...
From src/getself.c:
Code: Select all
#if defined(SELFEXE_LINUX)
#include <limits.h>
#include <stdlib.h>
const char *get_self_executable(int argc, char **argv)
{
char res[PATH_MAX];
// On linux systems /proc/self/exe is always a symlink to the real executable, so we jsut resolve it
realpath("/proc/self/exe", res);
return res;
}
I think looking through the warning messages did it, as the above (Linux-specific) snippet is clearly buggy. char res[PATH_MAX] is really char* with PATH_MAX * sizeof(char) memory allocated for it. And the contents of the pointer expire when the execution returns from that particular function.
Maybe it only worked for other Linux-using people through luck. Referring to deallocated memory can make weird things happen.
By the way, I wonder how common realpath is preinstalled among Linux installations. I know eselect on Gentoo depends on it, but I'm not sure about if it comes as default on other distributions.
Re: Game crashes on startup
Posted: Thu May 13, 2010 8:21 pm
by darkgod
Hum taht could be a cause, try to make it malloc instead see if it helps.
realpath(), the function is part of POSIX api so it should be quite everywhere.
Re: Game crashes on startup
Posted: Thu May 13, 2010 8:32 pm
by Nerdanel
I changed it into malloc and got rid of the warning message. Nothing else has changed. I still get the same PANIC message and no game. I tried to have the executable at bin/Debug, bin, and at the root directory of the game, but no dice.
Re: Game crashes on startup
Posted: Thu May 13, 2010 10:30 pm
by darkgod
Can you try with a breakpoint on the line that trhows the error as to get a stack trace ?
src/lua/lauxlib.c:622
Re: Game crashes on startup
Posted: Fri May 14, 2010 8:09 am
by Nerdanel
Here's the stacktrace:
Code: Select all
#0 panic (L=0x68f1b0) at src/lua/lauxlib.c:622
#1 0x0000000000439cc1 in luaD_throw (L=0x68f1b0, errcode=2) at src/lua/ldo.c:104
#2 0x000000000043290c in luaG_errormsg (L=0x68f1b0) at src/lua/ldebug.c:627
#3 0x0000000000434d53 in lua_error (L=0x68f1b0) at src/lua/lapi.c:967
#4 0x000000000042f9dc in luaL_error (L=0x68f1b0, fmt=0x478bb9 "Unable to initialize: %s")
at src/lua/lauxlib.c:95
#5 0x000000000045c664 in luaopen_lanes (L=0x68f1b0) at src/lualanes/lanes.c:1810
#6 0x000000000040f5b0 in main (argc=1, argv=0x7fffffffde28) at src/main.c:427
That's not very useful, though. I got that much information by applying grep to the error message. There's an error in init_keepers().
Code: Select all
#0 init_keepers () at src/lualanes/lanes.c:294
#1 0x000000000045c63f in luaopen_lanes (L=0x68f1b0) at src/lualanes/lanes.c:1808
#2 0x000000000040f5b0 in main (argc=1, argv=0x7fffffffde28) at src/main.c:427
The backtrace for init_keepers isn't very informative either, but looking at the function I can determine it errors out due to luaL_loadbuffer.
Code: Select all
#0 luaL_loadbuffer (L=0x6a00a0, buff=0x68b2a0 "\033LuaQ", size=4101, name=0x478853 "=lanes_keeper")
at src/lua/lauxlib.c:593
#1 0x0000000000459ef5 in init_keepers () at src/lualanes/lanes.c:309
#2 0x000000000045c63f in luaopen_lanes (L=0x68f1b0) at src/lualanes/lanes.c:1808
#3 0x000000000040f5b0 in main (argc=1, argv=0x7fffffffde28) at src/main.c:427
And this is the luaL_loadbuffer function with its vaguely suspicious size_t size of which I already talked about:
Code: Select all
LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size,
const char *name) {
LoadS ls;
ls.s = buff;
ls.size = size;
return lua_load(L, getS, &ls, name);
}
Is 4101 a sensible value for size?
And this is the stacktrace for lua_load:
Code: Select all
#0 lua_load (L=0x6a00a0, reader=0x430bfe <getS>, data=0x7fffffffdc80, chunkname=0x478853 "=lanes_keeper")
at src/lua/lapi.c:867
#1 0x0000000000430c8f in luaL_loadbuffer (L=0x6a00a0, buff=0x68b2a0 "\033LuaQ", size=4101,
name=0x478853 "=lanes_keeper") at src/lua/lauxlib.c:595
#2 0x0000000000459ef5 in init_keepers () at src/lualanes/lanes.c:309
#3 0x000000000045c63f in luaopen_lanes (L=0x68f1b0) at src/lualanes/lanes.c:1808
#4 0x000000000040f5b0 in main (argc=1, argv=0x7fffffffde28) at src/main.c:427
Jumping ahead a few steps, here's the stacktrace for luaD_rawrunprotected from the execution that causes the error status:
Code: Select all
#0 luaD_rawrunprotected (L=0x6a00a0, f=0x43b273 <f_parser>, ud=0x7fffffffdba0) at src/lua/ldo.c:113
#1 0x000000000043b1b5 in luaD_pcall (L=0x6a00a0, func=0x43b273 <f_parser>, u=0x7fffffffdba0, old_top=16, ef=0)
at src/lua/ldo.c:463
#2 0x000000000043b45b in luaD_protectedparser (L=0x6a00a0, z=0x7fffffffdc10, name=0x478853 "=lanes_keeper")
at src/lua/ldo.c:513
#3 0x0000000000434b40 in lua_load (L=0x6a00a0, reader=0x430bfe <getS>, data=0x7fffffffdc80,
chunkname=0x478853 "=lanes_keeper") at src/lua/lapi.c:869
#4 0x0000000000430c8f in luaL_loadbuffer (L=0x6a00a0, buff=0x68b2a0 "\033LuaQ", size=4101,
name=0x478853 "=lanes_keeper") at src/lua/lauxlib.c:595
#5 0x0000000000459ef5 in init_keepers () at src/lualanes/lanes.c:309
#6 0x000000000045c63f in luaopen_lanes (L=0x68f1b0) at src/lualanes/lanes.c:1808
#7 0x000000000040f5b0 in main (argc=1, argv=0x7fffffffde28) at src/main.c:427
The C/Lua interface is so very annoying in ToME 4 too...
Re: Game crashes on startup
Posted: Fri May 14, 2010 8:41 am
by darkgod
Ahh lua lanes! (that the threading lib).
The easy solution is to disable it by commenting the luaopen_lanes() line in main.c, it's not YET used.
I believe the problem comes from the precompile lua chunk that lanes uses to initializes.
Try that:
* add
http://te4.org/dl/t-engine/lanes-keeper.lua in the game/thirdparty/ directory
* comment out lines 309/310 of src/lualanes/lanes.c and add a line to load the lua file, it should look like that:
Code: Select all
// if (luaL_loadbuffer( L, keeper_chunk, sizeof(keeper_chunk), "=lanes_keeper" ))
// return "luaL_loadbuffer() failed"; // LUA_ERRMEM
luaL_loadfile(L, "/lanes-keeper.lua");
* move the call to luaopen_lanes() in main.c after just before the call to
Code: Select all
luaL_loadfile(L, "/engine/init.lua");
* recompile and it SHOULD work
Re: Game crashes on startup
Posted: Fri May 14, 2010 9:28 am
by Nerdanel
Well, it worked, for the definition of work that now at least I get a different error...
This is when I try to run t-engine and my working directory is root directory for the game:
Code: Select all
WARNING: No bootstrap code found, defaulting to working directory for engine code!
LuaVM: Lua 5.1
[KEYBINDER] Loaded keybinds: move
[KEYBINDER] Loaded keybinds: actions
Loading tile border_7.png
Loading tile border_9.png
Loading tile border_1.png
Loading tile border_3.png
Loading tile border_8.png
Loading tile border_4.png
Loading tile border_7_sel.png
Loading tile border_9_sel.png
Loading tile border_1_sel.png
Loading tile border_3_sel.png
bind MOVE_DOWN function: 0xbc31a0
bind MOVE_UP function: 0xbc3130
bind ACCEPT function: 0xbc31e0
t-engine: brw_misc_state.c:290: emit_depthbuffer: Assertion `region->tiling != 1' failed.
Aborted
And this is what I get when my working directory is something else. I've tested bootstrap, game, game/engine, bin and bin/Debug.
Code: Select all
WARNING: No bootstrap code found, defaulting to working directory for engine code!
Lua Error: attempt to call a string value
At [C]:-1
PANIC: unprotected error in call to Lua API (Unable to initialize: attempt to call a string value)
I miss the T-Engine 3 way of doing things. It wasn't nearly as complicated...
Re: Game crashes on startup
Posted: Fri May 14, 2010 9:58 am
by Nerdanel
Here is the stacktrace from the emit_depthbuffer problem:
Code: Select all
#0 0x00007ffff6d0e1a5 in raise () from /lib/libc.so.6
#1 0x00007ffff6d0f5d0 in abort () from /lib/libc.so.6
#2 0x00007ffff6d072c1 in __assert_fail () from /lib/libc.so.6
#3 0x00007ffff1c1a385 in ?? () from /usr/lib64/dri/i965_dri.so
#4 0x00007ffff1c1efa4 in ?? () from /usr/lib64/dri/i965_dri.so
#5 0x00007ffff1c1419c in ?? () from /usr/lib64/dri/i965_dri.so
#6 0x00007ffff1cbc812 in ?? () from /usr/lib64/dri/i965_dri.so
#7 0x00007ffff1cb89ba in ?? () from /usr/lib64/dri/i965_dri.so
#8 0x00007ffff1cba426 in ?? () from /usr/lib64/dri/i965_dri.so
#9 0x00007ffff1ca1861 in ?? () from /usr/lib64/dri/i965_dri.so
#10 0x000000000040b04c in sdl_surface_toscreen (L=0x68f170) at src/core_lua.c:750
#11 0x000000000043ab00 in luaD_precall (L=0x68f170, func=0xafe3b0, nresults=0) at src/lua/ldo.c:319
#12 0x0000000000441771 in luaV_execute (L=0x68f170, nexeccalls=2) at src/lua/lvm.c:587
#13 0x000000000043adab in luaD_call (L=0x68f170, func=0xafe300, nResults=0) at src/lua/ldo.c:377
#14 0x00000000004348c0 in f_call (L=0x68f170, ud=0x7fffffffdc60) at src/lua/lapi.c:800
#15 0x0000000000439d50 in luaD_rawrunprotected (L=0x68f170, f=0x43488b <f_call>, ud=0x7fffffffdc60)
at src/lua/ldo.c:116
#16 0x000000000043b1b5 in luaD_pcall (L=0x68f170, func=0x43488b <f_call>, u=0x7fffffffdc60, old_top=336, ef=320)
at src/lua/ldo.c:463
#17 0x0000000000434969 in lua_pcall (L=0x68f170, nargs=1, nresults=0, errfunc=20) at src/lua/lapi.c:821
#18 0x000000000040e84e in docall (L=0x68f170, narg=1, nret=0) at src/main.c:68
#19 0x000000000040f144 in on_redraw () at src/main.c:252
#20 0x000000000040f8e9 in main (argc=1, argv=0x7fffffffde38) at src/main.c:524
The program received SIGABRT.
I have an Intel integrated graphics card.
Re: Game crashes on startup
Posted: Fri May 14, 2010 10:25 am
by madmonk
What Intel Graphics card?
There are known issues with some of these integrated cards. I had immense problems with stuff crashing until I got an external card!