I had a wierd situation when trying to build lua-sqlite3 (http://www.nessie.de/mroth/lua-sqlite3/) in my hardened/uclibc environment. If i only had require("sqlite3") the app would segfault upon exit. It works just fine in glibc.
The problem seems to be related pthreads. Se below.
I think any lua module using pthreads will have the same problem in uclibc.
Time Teras helped me to debug it:
gdb backtrace (needed to compile without ssp)
#0 0xb7f1ccb5 in _dl_debug_state () at ldso.c:79
#1 0xb7e9ea71 in do_dlclose (vhandle=0x8066270, need_fini=1) at libdl.c:585
#2 0xb7e9eb66 in dlclose (vhandle=0x8066270) at libdl.c:597
#3 0xb7edeb96 in ll_unloadlib (lib=0x8066270) at loadlib.c:64
#4 0xb7eded88 in gctm (L=0x804c008) at loadlib.c:288
#5 0xb7ec63a7 in luaD_precall (L=0x804c008, func=0x8052ec4, nresults=0) at ldo.c:319
#6 0xb7ec65aa in luaD_call (L=0x804c008, func=0x8052ec4, nResults=0) at ldo.c:376
#7 0xb7ec8888 in GCTM (L=0x804c008) at lgc.c:467
#8 0xb7ec88bc in luaC_callGCTM (L=0x804c008) at lgc.c:479
#9 0xb7eced25 in callallgcTM (L=0x804c008, ud=0x0) at lstate.c:195
#10 0xb7ec5977 in luaD_rawrunprotected (L=0x804c008, f=0xb7eced14 <callallgcTM>, ud=0x0)
#11 0xb7ecedb4 in lua_close (L=0x804c008) at lstate.c:209
#12 0x08049e1d in main (argc=2, argv=0xbffe0cf4) at lua.c:387
Here is the irc log:
so problem is solved
whats the problem?
<tteras> you need to link lua with -lpthread
<tteras> problem is that now only the sqlite so is linked with -lpthread
and when it is unloaded pthread.so is unloaded too
but since it overrides some stuff in uclibc havoc will follow
but linking lua binary with -lpthread will fix this since pthread.so won't be then unloaded
<ncopa> i see
<tteras> add -lpthread to lua makefile
emerging sqlite with USE=nothreadsafe walks around the problem. I'm not sure but it might be uclibc's pthread that does not support unloading.
Any advice from the embedded team?
This issue is ages old. Does the bug still occur with latest lua/uclibc?
Please reopen the bug if this is the case.