summaryrefslogtreecommitdiff
path: root/gtk2_ardour/linux_vst_gui_support.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-03-05 22:14:49 +0100
committerRobin Gareus <robin@gareus.org>2017-03-05 22:14:49 +0100
commite9385c2297a58ab61d14be1004369659c6567256 (patch)
treeabb69b654f307e906afbc4c7de27038b5de43dfc /gtk2_ardour/linux_vst_gui_support.cc
parent9089c1c6bfc650a3626fcd43f0a96f02cb507fa3 (diff)
Work around a crash at exit for Linux VST UIs abusing pthread-keys.
Diffstat (limited to 'gtk2_ardour/linux_vst_gui_support.cc')
-rw-r--r--gtk2_ardour/linux_vst_gui_support.cc27
1 files changed, 23 insertions, 4 deletions
diff --git a/gtk2_ardour/linux_vst_gui_support.cc b/gtk2_ardour/linux_vst_gui_support.cc
index b310227403..91ed0db96b 100644
--- a/gtk2_ardour/linux_vst_gui_support.cc
+++ b/gtk2_ardour/linux_vst_gui_support.cc
@@ -453,7 +453,29 @@ again:
}
}
- /*Drop out to here if we set gui_quit to 1 */
+
+ /* some plugin UIs (looking at you, u-he^abique), do set thread-keys
+ * and free, but not unset them.
+ *
+ * This leads to a double-free in __nptl_deallocate_tsd
+ * nptl/pthread_create.c:175 __pthread_keys[idx].destr (data);
+ * when the event-loop thread is joined.
+ *
+ * This workaround is dedicated to all the plugin-UI-devs
+ * who think their UI owns the complete process memory-space.
+ *
+ * NB. ardour itself does not use thread-keys for the
+ * VST event-loop thread, and anyway, this thread is joined
+ * only when ardour exit()s. If this would result in a leak,
+ * nobody will care.
+ */
+ if (!getenv ("ARDOUR_RUNNING_UNDER_VALGRIND")) {
+ for (pthread_key_t i = 0; i < PTHREAD_KEYS_MAX; ++i) {
+ if (pthread_getspecific (i)) {
+ pthread_setspecific (i, NULL);
+ }
+ }
+ }
return NULL;
}
@@ -532,9 +554,6 @@ void vstfx_exit()
/*We need to pthread_join the gui_thread here so
we know when it has stopped*/
- // BEWARE: some Plugin GUIs can crash if the thread local storage is free()d
- // after the shared library containing the destructor is already dl-closed.
- // (e.g u-he LXVST GUI, crash in __nptl_deallocate_tsd) :(
pthread_join(LXVST_gui_event_thread, NULL);
pthread_mutex_destroy (&plugin_mutex);
}