From 72db0916196181e65da32337c6cf4bb5aba816be Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 7 Apr 2021 02:25:23 +0200 Subject: [PATCH] Fix crash at exit with classic Faderport MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FaderPort::~FaderPort () can be called while FaderPort::map_gain() is called from FaderPort::periodic() ``` Thread 71 Crashed: 0      libardour_faderport.dylib          0x0000000110539c3a ArdourSurface::FaderPort::map_gain() + 138 1      libardour_faderport.dylib          0x000000011053996d ArdourSurface::FaderPort::periodic() + 109 2      libglibmm-2.4.1.dylib                  0x000000010bf21da8 Glib::TimeoutSource::dispatch(sigc::slot_base*) + 56 3      libglibmm-2.4.1.dylib                  0x000000010bf20c97 Glib::Source::dispatch_vfunc(_GSource*, int (*)(void*), void*) + 39 4      libglib-2.0.0.dylib                      0x000000010c012496 g_main_context_dispatch + 326 5      libglib-2.0.0.dylib                      0x000000010c01281a g_main_context_iterate + 474 6      libglib-2.0.0.dylib                      0x000000010c012b3f g_main_loop_run + 191 7      libpbd.dylib                                    0x000000010bcee42e BaseUI::main_thread() + 254 8      libglibmm-2.4.1.dylib                  0x000000010bf16373 (anonymous namespace)::call_thread_entry_slot(void*) + 35 9      libglib-2.0.0.dylib                      0x000000010c03dd0a g_thread_proxy + 90 10    libsystem_pthread.dylib              0x00007fff759e42eb _pthread_body + 126 11    libsystem_pthread.dylib              0x00007fff759e7249 _pthread_start + 66 12    libsystem_pthread.dylib              0x00007fff759e340d thread_start + 13 ``` While the GUI thread has already closed the MIDI ports in ~FaderPort and proceeded to take down the FP GUI. ``` Thread 0:: Dispatch queue: com.apple.main-thread 47    libgtkmm-2.4.1.dylib                    0x000000010ca69a56 Gtk::ComboBox::~ComboBox() + 22 48    libardour_faderport.dylib          0x000000011055a6e5 ArdourSurface::FPGUI::~FPGUI() + 149 49    libardour_faderport.dylib          0x000000011055a8b5 ArdourSurface::FPGUI::~FPGUI() + 21 50    libardour_faderport.dylib          0x0000000110551396 ArdourSurface::FaderPort::tear_down_gui() + 70 51    libardour_faderport.dylib          0x0000000110536507 ArdourSurface::FaderPort::~FaderPort() + 535 52    libardour_faderport.dylib          0x0000000110536b9e ArdourSurface::FaderPort::~FaderPort() + 14 53    libardour.dylib                              0x000000010ac13f08 ARDOUR::ControlProtocolManager::drop_protocols() + 168 54    libardour.dylib                              0x000000010b0ba7e4 ARDOUR::Session::destroy() + 212 55    libardour.dylib                              0x000000010b0bbe01 ARDOUR::Session::~Session() + 113 56    libardour.dylib                              0x000000010b0bdb5e ARDOUR::Session::~Session() + 14 --- libs/surfaces/faderport/faderport.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/surfaces/faderport/faderport.cc b/libs/surfaces/faderport/faderport.cc index 6a7b8fa237..e037e0a1b0 100644 --- a/libs/surfaces/faderport/faderport.cc +++ b/libs/surfaces/faderport/faderport.cc @@ -196,7 +196,7 @@ FaderPort::~FaderPort () { cerr << "~FP\n"; - all_lights_out (); + close (); if (_input_port) { DEBUG_TRACE (DEBUG::FaderPort, string_compose ("unregistering input port %1\n", boost::shared_ptr(_input_port)->name())); @@ -633,6 +633,7 @@ FaderPort::close () blink_connection.disconnect (); selection_connection.disconnect (); stripable_connections.drop_connections (); + periodic_connection.disconnect (); #if 0 stripable_connections.drop_connections ();