From 066df7cc1ae32d65ec031de524792d2f55589f9f Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 15 Dec 2023 04:28:23 +0100 Subject: [PATCH] LV2: fix crash when replicating stateful plugin on copy When copying a mono LV2 plugin to a stereo track, the state of the copied mono plugin is copied to the replicated instance. However at this point in time PBD::Stateful::ForceIDRegeneration is still enabled, and the state ID has not been set. This used to not be an issue. Older versions of liblilv handle non-existent paths just fine. However in lilv v0.24.20-10-gdd5e851 `lilv_path_absolute` was replaced with `zix_canonical_path` which returns NULL if a state file does not [yet] exist. This lead to a segfault due to strlen(NULL) in `serd_node_new_file_uri`: #0 strlen -- SEGV on unknown address 0x000000000000 #1 serd_node_new_file_uri () at /lib/x86_64-linux-gnu/libserd-0.so.0 #2 lilv_state_new_from_file () at /lib/x86_64-linux-gnu/liblilv-0.so.0 #3 ARDOUR::LV2Plugin::set_state(XMLNode const&, int) at ../libs/ardour/lv2_plugin.cc:2320 --- libs/ardour/plugin_insert.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index cb4d98991c..ed14a145d1 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -180,6 +180,7 @@ PluginInsert::set_count (uint32_t num) add_plugin (p); if (require_state) { + _plugins[0]->set_insert_id (this->id ()); XMLNode& state = _plugins[0]->get_state (); p->set_state (state, Stateful::current_state_version); delete &state;