Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory leak(s) in CLAP plugin #187

Open
messmerd opened this issue Dec 4, 2023 · 1 comment
Open

Possible memory leak(s) in CLAP plugin #187

messmerd opened this issue Dec 4, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@messmerd
Copy link

messmerd commented Dec 4, 2023

Describe the bug
The address sanitizer build of a CLAP host I'm developing indicates that there's a memory leak after I call the clap_plugin_factory->get_plugin_descriptor() function in the OctaSine v0.9 CLAP plugin.

I don't know Rust, so I couldn't tell if there were any ownership issues in src/plugin/clap/descriptor.rs or other files when I read them.

It's possible this could be a false positive from my address sanitizer, but none of the other CLAP plugins I've tested so far have had this issue.

What did you try to do
Load the OctaSine v0.9.clap shared library in an address sanitizer build of a CLAP host, then step through the CLAP plugin initialization until it calls the clap_plugin_factory->get_plugin_descriptor() function. Skipping this function call avoids the memory leak message from the address sanitizer:

if (/*plugin is OctaSine*/) {
    static const clap_plugin_descriptor desc {
        clap_version{1, 0, 3},
        "OctaSine", // id
        "OctaSine", // name
        "Joakim Frostegard", // vendor
        "https://octasine.com", // url
        nullptr, // manual
        nullptr, // support
        "0.9.0", // version
        nullptr, // description
        (const char* const[]){ // features
            CLAP_PLUGIN_FEATURE_INSTRUMENT,
            CLAP_PLUGIN_FEATURE_SYNTHESIZER,
            CLAP_PLUGIN_FEATURE_STEREO,
            nullptr
        }
    };
    m_descriptor = &desc;
} else /*all other plugins*/ {
    m_descriptor = m_factory->get_plugin_descriptor(m_factory, m_index);
}

During plugin instantiation and usage, there appear to be additional memory leaks, but I haven't investigated them yet. The code above is enough to avoid the memory leak message during the initial scan: shared library loading + entry/init/get_factory + descriptor reading + deinit.

Expected behavior
No memory leaks.

Screenshots
N/A

Log file contents

I have address sanitizer output, but it probably won't be very useful, though it is apparently 6 bytes leaked.

Software:

  • DAW: LMMS (dev version with CLAP support)
  • OS: Linux Mint 21.1
  • OctaSine version: 0.9

Additional context
N/A

@greatest-ape
Copy link
Owner

Thanks, I'll look into it.

@greatest-ape greatest-ape added the bug Something isn't working label Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants