fluidlite-rs icon indicating copy to clipboard operation
fluidlite-rs copied to clipboard

Memory leak in test case `settings_ref`

Open icmccorm opened this issue 7 months ago • 0 comments

I've been experimenting with a version of Miri that can execute foreign functions. It interprets the LLVM bytecode that is produced during a crate's build process. We're hoping our results can assist with the Krabcake project.

I ran your test cases in this tool, and it found a few memory leaks in the test settings_ref. It seems like the Drop implementation of Settings is never called, since Settings is consumed by Settings::into_ptr().

Instead, maybe Settings could spawn a SettingsRef object tied to its lifetime using a pattern like this:

impl Settings {
    pub(crate) fn as_ref(&self) -> SettingsRef<'_> {
        unsafe { SettingsRef::from_ptr(self.handle) }
    }
}

icmccorm avatar Nov 28 '23 04:11 icmccorm