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 729ff35faf

```
#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<boost::shared_ptr<ARDOUR::Stripable>, std::allocator<boost::shared_ptr<ARDOUR::Stripable> > >&, 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<char, std::char_traits<char>, std::allocator<char> > const&)
    (this=0x5555599b6d10, howmany=1, name_template="VCA %n") at ../libs/ardour/vca_manager.cc:105
```
This commit is contained in:
Robin Gareus 2022-03-03 17:43:37 +01:00
parent 84c51a1411
commit e33d131174
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -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);