summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-12-12 03:13:16 +0100
committerRobin Gareus <robin@gareus.org>2016-12-12 03:13:16 +0100
commitd3803c54dec08be11c2eab90c8e4441c89cb4e42 (patch)
tree8f9ce54720b44f8cdc0103d192049e62f75b14bf
parentb52bf1a42c71ae943eaff2bca4c309618c173ab3 (diff)
Fix a potential deadlock/crash (here tape-track peak-file)
read_peaks_with_fpp() already holds _lock, build_peaks_from_scratch() takes the _lock again. Depending on glib[mm] and the threading lib it may either result in a deadlock, or with EDEADLK in undefined behavior when a non-recursive lock is released twice.
-rw-r--r--libs/ardour/audiosource.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc
index 123bc22918..12c12099d5 100644
--- a/libs/ardour/audiosource.cc
+++ b/libs/ardour/audiosource.cc
@@ -387,7 +387,9 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
if (statbuf.st_size < expected_file_size) {
warning << string_compose (_("peak file %1 is truncated from %2 to %3"), _peakpath, expected_file_size, statbuf.st_size) << endmsg;
+ lm.release(); // build_peaks_from_scratch() takes _lock
const_cast<AudioSource*>(this)->build_peaks_from_scratch ();
+ lm.acquire ();
if (g_stat (_peakpath.c_str(), &statbuf) != 0) {
error << string_compose (_("Cannot open peakfile @ %1 for size check (%2) after rebuild"), _peakpath, strerror (errno)) << endmsg;
}