Skip to content

VST3/AUv2: ignore a param rescan requested from inside init() - #580

Merged
defiantnerd merged 2 commits into
free-audio:nextfrom
Audio-Damage-Inc:fix-rescan-during-init
Oct 8, 2026
Merged

defiantnerd merged 2 commits into
free-audio:nextfrom
Audio-Damage-Inc:fix-rescan-during-init

Conversation

@Crandall1

Copy link
Copy Markdown

Fixes a crash when a plugin calls clap_host_params::rescan() from its own init().

Cause
Clap::Plugin::createInstance calls the plugin's init() (in connectClap) before it returns. The VST3 and AUv2 wrappers only assign _plugin from that return value. A rescan sent during init() therefore reaches ClapAsVst3::param_rescan or WrapAsAUV2::param_rescan while _plugin is still empty. The first line of each, setupParameters(_plugin->_plugin, ...), then dereferences a null shared_ptr.

We hit this by loading a default preset in init() and sending a rescan with CLAP_PARAM_RESCAN_VALUES | CLAP_PARAM_RESCAN_INFO afterwards. The CLAP build was fine; the VST3 and AUv2 builds segfaulted on instantiation.

Fix
Both param_rescan implementations return early while _plugin is null. Nothing is lost: initialize() calls setupParameters as soon as createInstance returns, so it reads the plugin's parameters as they stand after init().

🤖 Generated with Claude Code

The plugin's init() runs inside Clap::Plugin::createInstance, before the
wrapper has assigned _plugin. A plugin that calls params->rescan() from
init() - after loading a default state, say - reached param_rescan with
_plugin still empty and dereferenced it.

There is nothing to rescan at that point: both wrappers set the
parameters up as soon as createInstance returns, so the request is
dropped.
@defiantnerd
defiantnerd self-requested a review October 8, 2026 15:58
@defiantnerd
defiantnerd merged commit 0cd88b9 into free-audio:next Oct 8, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants