Re: segfault on x86_64 using musl libc

  • From: Florian Weimer <fw@xxxxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 17 Jul 2012 22:14:38 +0200

* 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-)

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.

Other related posts: