On 2016/02/16 12:20, Henrik Friedrichsen wrote: > Hey, > > On Tue, Feb 16, 2016 at 11:08:58AM +0000, Stuart Henderson wrote: > > Good point. Try adding > > "prosody:setenv=LD_PRELOAD=/usr/lib/libpthread.so:tc=daemon:" to > > /etc/login.conf and start it via the rc script. > > This works. Seems that libpthread is not loaded by the linker automatically. > Not sure I understand why, as it's already loaded before by the lua binary, in > which case it works fine.
libpthread is special because it overrides various functions in libc via weak symbols. In order for this to work properly, libpthread must be loaded before the main process starts running. When you do 'require("dbdmysql")' it loads dbdmysql.so dynamically at runtime, this pulls in libmysqlcient and its dependencies (including libpthread) but by this point it's too late to load libpthread. Using LD_PRELOAD ensures that libpthread is pulled in early enough that it can be used. $ echo 'require("dbdmysql")' | lua51 lua51: error loading module 'dbdmysql' from file '/usr/local/lib/lua/5.1/dbdmysql.so': Cannot load specified object stack traceback: [C]: ? [C]: in function 'require' stdin:1: in main chunk [C]: ? $ echo 'require("dbdmysql")' | LD_PRELOAD=/usr/lib/libpthread.so lua51 $