Which threading library are we using?

25 Sep 2007 • 2 min read

FreeBSD-6 ships with 3 threading libraries (oldest to newest)

  • libc_r
  • libphread (really libkse)
  • libthr

They should all be ABI compatible with each other and as such are easily interchangeable using libmap.conf. However, that's not always the case....

In our efforts to fix threaded python on sparc64 and a few other threading weirdness on x86 we shipped a default libmap.conf that defaulted to using libthr for everything. Many moons passed and everything was good, until LavaJoe discovered a little problem with this. Basically applications are built against libpthread but run using libthr. libpthread has some symbols that shouldn't be used, but are still embedded so even if libmap.conf says use libthr, libpthread is really used. So you could have 2 threading libraries loaded which is the source of the issue.

So our present solution is not to build or install libc_r OR libkse. Instead we set the default threading library to libthr and provide symlinks for libc_r and libpthread. This seems to works very well, but with 1 caveat - applications which embedded private symbols to libkse or libc_r no longer link correctly. So far this is just glib, which has proven to be a most troublesome library over time and is so once more! The solution is to re-emerge the library you're failing to link to and then it should work.

If anyone is concerned by this you need not be - FreeBSD-7 will ship like this by default.