Re: segfault on x86_64 using musl libc

  • From: John Spencer <maillist-luajit@xxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 17 Jul 2012 22:41:43 +0200

On 07/17/2012 10:14 PM, Florian Weimer wrote:
* Mike Pall:

John Spencer wrote:
Rich came up with a clever portable (POSIX) way that could be used instead
of the existing non-threadsafe fallback code for OSX/OpenBSD/non-TLS.
There's no way I can drag a dependency on pthreads into the LuaJIT
core, because it's meant to be embedded. Pthreads needs to be loaded
early on (or bad things will happen), so the executable must be
linked with it. But that would kill the ability to use the LuaJIT
shared library as a drop-in replacement for Lua.
Yet another reason for __thread. 8-)


here's the author's reasoning why it is not yet implemented:
<http://www.murga-linux.com/puppy/viewtopic.php?p=640815#640815>http://www.openwall.com/lists/musl/2012/07/16/4

it occurs to me that his arguments against it are pretty reasonable.

You could use a weak reference to pthread_getspecific&c and fall back
to a global variable if the symbols aren't available.

But perhaps on musl provides these functions as part of libc?  Then
you could safely link against these symbols for musl platforms.


indeed, musl implements pthreads in libc.so/.a (libpthread.* is simply an empty dummy), because threading is an integral part of musl's design. there's no __MUSL__ or similar symbol though to test for its existence. imo a Makefile flag to enable the portable pthread code would make most sense.


Other related posts: