From e33d1311748e2a27f92cd8b8ffbac6e85956f7b2 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 3 Mar 2022 17:43:37 +0100 Subject: [PATCH] Fix deadlock when creating VCAs VCAManager::create_vca sets PI::order while holding the VCAManager:lock mutex. PI order changes emit a "changed" signal which in turn can result in querying a list of all strips (reassign_track_numbers) which requires the VCA mutex: See also 729ff35faf89f7ff6a68 ``` #2 Glib::Threads::Mutex::Lock::Lock(Glib::Threads::Mutex&) (this=0x7fffffffb070, mutex=...) at /usr/include/glibmm-2.4/glibmm/threads.h:687 #3 ARDOUR::VCAManager::vcas[abi:cxx11]() const (this=0x5555599b6d10) at ../libs/ardour/vca_manager.cc:77 #4 ARDOUR::Session::get_stripables(std::__cxx11::list, std::allocator > >&, ARDOUR::PresentationInfo::Flag) const (this=0x55555bf03910, sl=std::__cxx11::list = {...}, fl=127) at ../libs/ardour/session.cc:3949 #5 ARDOUR::Session::ensure_stripable_sort_order() (this=0x55555bf03910) at ../libs/ardour/session.cc:2634 #6 ARDOUR::Session::notify_presentation_info_change(PBD::PropertyChange const&) (this=0x55555bf03910, what_changed=...) at ../libs/ardour/session.cc:7016 [ .. connect same thread ..] #13 ARDOUR::PresentationInfo::send_static_change(PBD::PropertyChange const&) (what_changed=...) at ../libs/ardour/presentation_info.cc:113 #14 ARDOUR::PresentationInfo::set_order(unsigned int) (this=0x5555619ceca0, order=5) at ../libs/ardour/presentation_info.cc:288 #15 ARDOUR::Stripable::set_presentation_order(unsigned int) (this=0x5555619ce8a0, order=5) at ../libs/ardour/stripable.cc:55 #16 ARDOUR::VCAManager::create_vca(unsigned int, std::__cxx11::basic_string, std::allocator > const&) (this=0x5555599b6d10, howmany=1, name_template="VCA %n") at ../libs/ardour/vca_manager.cc:105 ``` --- libs/ardour/vca_manager.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/ardour/vca_manager.cc b/libs/ardour/vca_manager.cc index ca50ea576e..7b929c2352 100644 --- a/libs/ardour/vca_manager.cc +++ b/libs/ardour/vca_manager.cc @@ -86,6 +86,7 @@ VCAManager::create_vca (uint32_t howmany, std::string const & name_template) uint32_t n_stripables = _session.nstripables (); { + PresentationInfo::ChangeSuspender cs; Mutex::Lock lm (lock); for (uint32_t n = 0; n < howmany; ++n) { @@ -102,7 +103,7 @@ VCAManager::create_vca (uint32_t howmany, std::string const & name_template) BOOST_MARK_VCA (vca); vca->init (); - vca->set_presentation_order (n + n_stripables); + vca->set_presentation_order (n + n_stripables); /* EMIT SIGNAL */ _vcas.push_back (vca); vcal.push_back (vca);