From: Jonathan Woithe <jwoithe@ph...> - 2008-03-19 22:57:03
Over last weekend I accidently triggered an odd bug which should probably be
fixed before 2.0. The problem occurs if jackd has RT privileges but has its
maximum RT priority set at something less than 98. If this is the case
jackd will crash on startup, often with a corrupted callback trace.
Some background: up until recently I ran jackd with a maximum RT priority of
80. When using "-P60" this was fine until the RT watchdog code was merged
(specifically, rev934 worked OK while rev942 showed up the problem). The
new watchdog code attempts to set an RT thread priority of 98, which fails
if the maximum priority allowed is less than this.
There are two problems I see. The first is that the user was given no
indication that this is what the problem was. All you get is an "Abort" and
(if enabled) a core dump. It would be nice if ffado could check whether
sufficient RT priorities were available and report if there's a problem.
The strange thing about this particular issue is my second problem: this
situation *should* already be dealt with cleanly. The watchdog uses the
PosixThread object to implement its threads, and in PosixThread::Start() the
results of all the pthread_*() functions are all checked for errors.
However, in my case none of these returned errors. The crash occurred in
pthread_create() whenever the preceeding pthread_attr_setschedpolicy() and
pthread_attr_setschedparam() calls were executed (neither of which returned
an error condition). I should also note that from memory the crash was
during the Start() call for the Check thread (which makes sense since that's
the one which runs with an elevated priority).
Changing jackd's maximum priority to 98 cured the crash.
Given that the crash occured in pthread_create() I kind of ran into a dead
end while checking this. Does anyone else have ideas about this? If not
I'll just add a check for the maximum allowed priority to Watchdog::start(),
but to me this just seems to be papering over some obscure underlying