lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Is there any 'gotchas' to using luaL_openlibs() from multiple OS threads with separate Lua states?

I am getting a rash of these while opening new Lua states en masse (but only when opening new states):

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x282028b0 (LWP 100257)]
0x280d047a in lua_newstate () from /usr/local/lib/
(gdb) bt
#0  0x280d047a in lua_newstate () from /usr/local/lib/
#1  0x280c5c48 in lua_rawget () from /usr/local/lib/
#2  0x280d47c4 in luaL_findtable () from /usr/local/lib/
#3  0x280d4ce9 in luaL_openlib () from /usr/local/lib/
#4  0x280d4e07 in luaL_register () from /usr/local/lib/
#5  0x280d59ca in luaopen_base () from /usr/local/lib/
#6  0x280c9926 in lua_resume () from /usr/local/lib/
#7  0x280c9d15 in lua_resume () from /usr/local/lib/
#8  0x280c5863 in lua_call () from /usr/local/lib/
#9  0x280de481 in luaL_openlibs () from /usr/local/lib/
#10 0x00000001 in ?? ()
#11 0x00000000 in ?? ()
#12 0x2820dfd0 in ?? ()
#13 0x2820dfd0 in ?? ()
#14 0x00000064 in ?? ()
#15 0xbe3e8f98 in ?? ()
#16 0x08049d9b in worker_run (a=0x283bd448) at main.c:281
Previous frame inner to this frame (corrupt stack?)

Now the last line makes me think I am doing something asinine within some unrelated code. But I thought I would ask just to make sure.

On a related (sorta) note, I was testing various third-party Lua C Modules (like LuaSQL). Strangely, even without enabling thread-safety on the mysql and pgsql client libs everything ran great. This is at decent levels of concurrency (100 threads using 100 Lua states with 100 modules loaded and connections to the DB). Running around 800-2000 TPS with millions of select/insert/update transactions, and not a peep. Do you really need "thread-safe" builds of these libs when using each instance of the modules only from the Lua state that requir()ed it? Or am I just getting lucky?