Skip to content

VST3/CLAP wrappers fail to call their internals' drop glue when destroyed #222

@estroBiologist

Description

@estroBiologist

When removing/destroying an instance of a VST3/CLAP plugin made with nih-plug (using nih-plug-egui for the UI) inside a host DAW, the plugin's drop glue consistently fails to run. After some debugging, I was able to track this down to an incorrect Arc refcount in the wrapper code. This leaks an arbitrary amount of memory every time - in the case of my own sampler plugin, anywhere up to hundreds of megabytes.

Tested on FL Studio 2024 and Reaper v7.40 using VST3 and CLAP. Both print an equivalent nih_debug_assert_eq!() failure:

VST3: Debug assertion failed: Arc::strong_count(&self.inner) != 1 inside <Vst3Wrapper as Drop>::drop(&mut self)

CLAP: Debug assertion failed: Arc::strong_count(&this) != 1 inside unsafe extern "C" fn destroy(plugin: *const clap_plugin)

In the case of CLAP, I was able to check the refcount at the point of the assertion failure:

Image

The problem still occurs if the plugin window is never opened.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions