Skip to content

Allocation is leaked when jack_activate fails #232

Description

@SludgePhD

let mut callback_context = Box::new(CallbackContext {
client,
notification: notification_handler,
process: process_handler,
is_valid_for_callback: AtomicBool::new(true),
has_panic: AtomicBool::new(false),
});
CallbackContext::register_callbacks(&mut callback_context)?;
let res = j::jack_activate(callback_context.client.raw());
match res {
0 => Ok(AsyncClient {
callback: Some(callback_context),
}),
_ => {
mem::forget(callback_context);
Err(Error::ClientActivationError)
}
}

The mem::forget will leak the callbacks and the Box that was allocated earlier in the method.

Activity

  1. SludgePhD commented on Jun 8, 2026

    @SludgePhD
    Author

    It looks like there are unexplained mem::forget calls all over the library. If the intent is to prevent a malicious user error from panicking in Drop, that should probably be done without causing an unconditional memory leak.

  2. wmedrano commented on Jun 8, 2026

    @wmedrano
    Member

    We can probably do less mem::forget though I'd have to read the JACK API again.

    If I recall, some of this was intentional. JACK may hold on to some references and it is unclear when it is absolutely clear to reclaim them. For example, perhaps the activate failed but JACK still wants to call the thread_init_callback or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions