If I execute that function multiple times I get the error shared memfd open() failed: Too many open files and my app crashes.
I decided to check the open files with lsof -u <USER> 2>/dev/null | grep -E "<APP_NAME>" | wc -l) and noticed that around 4 FIFO files gets open and they never get deleted until it reaches the maximum number of file descriptor in the system.
I noticed that frida-node calls frida_device_manager_close when dropping DeviceManagerref here, and here. We are currently not calling frida_device_manager_close in rust.
The next code seems to be working.
impl<'a> Drop for DeviceManager<'a> {
fn drop(&mut self) {
let mut error: *mut frida_sys::GError = std::ptr::null_mut();
unsafe {
frida_sys::frida_device_manager_close_sync(
self.manager_ptr,
std::ptr::null_mut(),
&mut error,
);
frida_sys::frida_unref(self.manager_ptr as _)
}
}
}
I have a function like the next one:
If I execute that function multiple times I get the error
shared memfd open() failed: Too many open files
and my app crashes.I decided to check the open files with
lsof -u <USER> 2>/dev/null | grep -E "<APP_NAME>" | wc -l)
and noticed that around 4 FIFO files gets open and they never get deleted until it reaches the maximum number of file descriptor in the system.I noticed that
frida-node
callsfrida_device_manager_close
when droppingDeviceManager
ref here, and here. We are currently not callingfrida_device_manager_close
in rust.The next code seems to be working.
I will be creating a PR for this.