NPTL-hell
Update:
This shouldn’t really be any problem any more with any of the more recent distros. I keep this page around for users of old distributions.
Update:
There’s a fix for this in the making. A patch against jack 0.98.8 is here and should be used when your system reports NPTL 0.60 (see below).
The fix is included in newer jackd versions, so no need to apply manually. Anyways, of course this does not fix other programs using SCHED_FIFO for threads they create themselfes.. So maybe for jack clients one still needs the LD_ASSUME_KERNEL workaround..
libc’s with NPTL 0.61 should be ok with current cvs. package maintainers are encouraged to follow jackit-devel atm as this is an important fix.
Update:
What is the NPTL-hell?
It is a bug in some versions of the Native Posix Threading Library (NPTL) which causes attempts to aquire realtime scheduling priorities to fail silently (that is: without the pthread function call returning an error code). In the case of jackd this can cause xruns or zombification of jack clients, etc.
Here’s a debian bug report describing the causes for the NPTL weirdnesses on certain systems:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=266507
See the Jack-FAQ for info on some of the issues jackd can have with an NPTL-enabled libc. Be sure to read it if you use linux 2.6.x or have a 2.4.x kernel with NPTL support patched into it..
Basically it goes like this: If you use 2.6.x and an NPTL libc chances are that you get very weird behaviour from jackd. The fix consists of exporting the environment variable LD_ASSUME_KERNEL. Set it to some value like 2.4.22 (look here for a detailed explanation on what this does). This will prevent libc from using NPTL, thus working around some bugs in jackd with respect to NPTL. Run jackd like this:
LD_ASSUME_KERNEL=2.4.22 jackd -R -d alsa ....
Besides jackd clients might suffer from the same bug, so it’s probably best to run all clients like:
LD_ASSUME_KERNEL=2.4.22 qjackctl
or
LD_ASSUME_KERNEL=2.4.22 ardour
I created a little script called rrt for this purpose. It consists of only one line. Here you go:
LD_ASSUME_KERNEL=2.4.22 $@
Put that command into a text file called “rrt” or whatever you prefer, chmod +x it, and put it in your path, then use it like:
rrt jackd ... rrt ardour
For your ~/.jackdrc (which tells jack clients how to start a client automatically if there isn’t one already running) you can’t use the rrt script above because jack assumes that the first part of the command line is the path to the jack command (and not the rrt script). just make a second script called rrt-jackd containing:
LD_ASSUME_KERNEL=2.4.22 /usr/bin/jackd $@
and set your ~/.jackdrc to something like:
rtt-jackd -R -d alsa (normal options here...)
If you’re unsure whether the libc you’re using actually has NPTL enabled, the easiest way to find out is to run it as if it were a normal executable:
pnambic@sokoban:~> /lib/libc.so.6
GNU C Library 20040808 release version 2.3.4, by Roland McGrath et al.
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6).
Compiled on a Linux 2.6.7 system on 2004-08-12.
Available extensions:
GNU libio by Per Bothner
crypt add-on version 2.1 by Michael Glad and others
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
Thread-local storage support included.
For bug reporting instructions, please see:
<http ://www.gnu.org/software/libc/bugs.html>.
The keyword to look for is “Native POSIX Threads Library”, of course. And if that doesn’t work, use the following command:
getconf GNU_LIBPTHREAD_VERSION
Good read, thanks.