Valgrind reports invalid reads when mainloop, context and core are dropped.
Code that triggers the valgrind messages:
use pipewire::*;
use std::{rc::Rc};
fn main() {
pipewire::init();
let mainloop = Rc::new(MainLoop::new().expect("Failed to create main loop"));
let context = Context::new(&mainloop.get_loop()).expect("Failed to create context");
let core = context.connect().expect("Failed to connect to core");
second(&core, mainloop);
}
fn second(core: &Core, mainloop: Rc<MainLoop>) {
println!("core: {:?}, loop: {:?}", core, mainloop);
}
The call to fn second
is essential, the messages do not show up without it.
The code was run using
G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=20 --trace-children=yes <executable>