dbus2 / zbus-old

Rust D-Bus crate.
https://gitlab.freedesktop.org/dbus/zbus
Other
49 stars 13 forks source link

Leak of ConnectionInner #210

Closed zeenix closed 1 year ago

zeenix commented 3 years ago

Seems at some point we've started to leak ConnectionInner, most likely through some cyclic Arc references. You can see the leak through applying this patch:

diff --git a/zbus/src/azync/connection.rs b/zbus/src/azync/connection.rs
index 09cf2cdc..c7a465d3 100644
--- a/zbus/src/azync/connection.rs
+++ b/zbus/src/azync/connection.rs
@@ -127,6 +127,12 @@ struct ConnectionInner {
     signal_subscriptions: Mutex<HashMap<u64, SignalSubscription>>,
 }

+impl Drop for ConnectionInner {
+    fn drop(&mut self) {
+        println!("Conn: {:?} dropped", self);
+    }
+}
+

and running cargo t basic_iface -- --nocapture (it won't print anything).


While my PR (!377) avoids more cyclic refs, it unfortunately doesn't address this issue fully. However, I've a feeling that the new internal WeakConnection API !377 adds, will be helpful in solving this regression.

zeenix commented 2 years ago

mentioned in commit b42eb2b64c0ec5588b77147210990919148730ef