Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 189804 - dev-lang/lua should be linked with -lpthread on uclibc
Summary: dev-lang/lua should be linked with -lpthread on uclibc
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Embedded Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-22 09:11 UTC by Natanael Copa
Modified: 2009-03-22 09:48 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Natanael Copa 2007-08-22 09:11:49 UTC
Hi,

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)

(gdb) where
 #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)
     at ldo.c:116
 #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:

<tteras> :)
 so problem is solved
<ncopa> cool
 whats the problem?
<tteras> you need to link lua with -lpthread
<ncopa> ah....
<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
Comment 1 Natanael Copa 2007-08-22 13:30:59 UTC
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.

Comment 2 Matti Bickel (RETIRED) gentoo-dev 2007-09-18 08:52:08 UTC
Any advice from the embedded team?
Comment 3 Matti Bickel (RETIRED) gentoo-dev 2009-03-22 09:48:10 UTC
This issue is ages old. Does the bug still occur with latest lua/uclibc?
Please reopen the bug if this is the case.