[Ardour-Dev] Hello, some tech talk, etc.

Razvan Cojocaru razvanco at gmx.net
Tue Jul 3 07:59:09 PDT 2012


Hello,

we've spoken previously on IRC, my name's Razvan, I've been writing
C/C++ code for quite a while now, and I'm also a Free Software / Open
Source enthusiast. You may, or may not, be familiar with my humble
project xCHM (won't post a link for fear of the message being marked as
spam, but Google know about it).

I've commented on Mantis issue "0002709: Ardour crashes very often while
zooming", I believe that it's quite likely that the fault lies in the
fact that a non-recursive mutex is being used there. I can't yet
reproduce the problem, maybe later I'll be able to, but in any case, in
an application such as Ardour I think recursive mutexes are a good idea.

I've also been looking at "0002799: crash on zooming into tape track",
and while I'm not sure I've got the culprit just yet, I did run into
this problem:

--- CUT HERE ---
JACK COMMAND: /usr/bin/jackd -p 128 -R -P 60 -T -d alsa -n 2 -r 48000 -p
1024 -d hw:0,0
jackd 0.121.3

JACK compiled with System V SHM support.
cannot lock down memory for jackd (Cannot allocate memory)
loading driver ..
apparent rate = 48000
creating alsa driver ...
hw:0,0|hw:0,0|1024|2|48000|0|0|nomon|swmeter|-|32bit
control device hw:0
configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback
JACK: unable to mlock() port buffers: Cannot allocate memory
JACK: unable to mlock() port buffers: Cannot allocate memory
loading bindings from gtk2_ardour/mnemonic-us.bindings

subgraph starting at ardour timed out (subgraph_wait_fd=12, status = 0,
state = Triggered, pollret = 0 revents = 0x0)
pp: cannot clean up byte from graph wait fd (Resource temporarily
unavailable)
bad status (-1) for client ardour handling event (type = 8)

**** alsa_pcm: xrun of at least 1.382 msecs

jack main caught signal 12
--- CUT HERE ---

Leaving aside for a moment why that happens, what happened was this:

1. Jack could not allocate memory and crashed (for some reason, with
signal 12).

2. Roughly at libs/ardour/audioengine.cc:185, jack_activate() returns 0
(which means success), _before_ Jack dies.

3. Ardour thinks Jack started and proceeds to do all kinds of bad things.

4. Ardour crashes.

The solution seems to be to check errno as well. jack_activate() won't
help out, but after calling it (and failing), my errno is 22, and
strerror(errno) is "Cannot allocate memory".

So the code in audioengine.cc becomes:

if (jack_activate() == 0 && errno == 0) {
// ...
} else {
	if(errno) {
		error << strerror(errno) << endmsg;
	}
}

This still does not help with the Jack issue, but at least Ardour
reports the problem and doesn't just crash.


Happy thoughts,
Razvan


More information about the Ardour-Dev mailing list