+ /* 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);
+ }
+ }
+ }