Discussion:
Lua and dlopen(3)
Christian Koch
2014-02-20 03:53:18 UTC
Permalink
Hi all,

I've been playing with Lua quite a bit these days, especially building
extensions to it. Sometimes, however, I encounter an error like this:

Cannot dlopen non-loadable /usr/lib/libpthread.so.1

After a bit of research, I found that it is actually the interpreter's fault.
From the man page dlfcn(3):

The error ``cannot dlopen non-loadable /usr/lib/libpthread.so.1'' is
generated when a program dlopen()s a module that needs libpthread but
isn't linked against it itself.

As expected, my Lua extensions actually work if I load them with my own custom
build of Lua linked against libpthread.

Furthermore, Lua from pkgsrc isn't linked against libpthread either.

I think it makes sense to provide Lua built this way. I would just complain to
the pkgsrc folks, but since Lua comes with the system, I don't know if it's best
to fix this here, or at pkgsrc, or both. Or maybe dlopen(3) itself needs to be
tweaked.

Since this problem affects other packages (e.g. databases/lua-tokyocabinet), I
guess I should report something to the pkgsrc list, regardless?

-Christian
David Holland
2014-02-20 06:09:11 UTC
Permalink
Post by Christian Koch
As expected, my Lua extensions actually work if I load them with my
own custom build of Lua linked against libpthread.
Furthermore, Lua from pkgsrc isn't linked against libpthread either.
Is Lua threaded? I was under the impression that it isn't.

(Also, some stuff in -current was rearranged fairly recently to
mitigate this problem; are you using -current or -6?)
--
David A. Holland
***@netbsd.org
David Laight
2014-02-20 08:28:54 UTC
Permalink
Post by David Holland
Post by Christian Koch
As expected, my Lua extensions actually work if I load them with my
own custom build of Lua linked against libpthread.
Furthermore, Lua from pkgsrc isn't linked against libpthread either.
Is Lua threaded? I was under the impression that it isn't.
Or rather, is Lua thread safe?

David
--
David Laight: ***@l8s.co.uk
Jan Danielsson
2014-02-20 16:11:30 UTC
Permalink
Post by David Laight
Post by David Holland
Post by Christian Koch
As expected, my Lua extensions actually work if I load them with my
own custom build of Lua linked against libpthread.
Furthermore, Lua from pkgsrc isn't linked against libpthread either.
Is Lua threaded? I was under the impression that it isn't.
Or rather, is Lua thread safe?
The library functions are reentrant (everything lives in lua_State
contexts), but a single lua_State can't be used simultaneously among
multiple threads.

/Jan
Christian Koch
2014-02-20 19:01:12 UTC
Permalink
Post by David Holland
(Also, some stuff in -current was rearranged fairly recently to
mitigate this problem; are you using -current or -6?)
I'm running 6.0.1. The "stuff" you're referring to is related to dlopen(3) ?
IMO that's a better solution, because it solves a bigger problem.

-Christian
Lourival Vieira Neto
2014-02-21 14:46:20 UTC
Permalink
Hi Christian,
Post by Christian Koch
Post by David Holland
(Also, some stuff in -current was rearranged fairly recently to
mitigate this problem; are you using -current or -6?)
I'm running 6.0.1. The "stuff" you're referring to is related to dlopen(3) ?
IMO that's a better solution, because it solves a bigger problem.
-Christian
I also think that should be a better solution; as Lua doesn't depend
on libpthread, it shouldn't be linked with it.

Regards,
--
Lourival Vieira Neto
Loading...