Bug 90005

Summary: dbus connection referencing issue in test-relay
Product: dbus Reporter: Ralf Habacker <ralf.habacker>
Component: coreAssignee: D-Bus Maintainers <dbus>
Status: RESOLVED FIXED QA Contact: D-Bus Maintainers <dbus>
Severity: normal    
Priority: medium Keywords: patch
Version: 1.8   
Hardware: Other   
OS: All   
Whiteboard: review+
i915 platform: i915 features:
Bug Depends on: 90004    
Bug Blocks:    
Attachments: bzipped2 stderr.log
Fix 'dbus connection referencing issue in test-relay'.

Description Ralf Habacker 2015-04-13 06:44:11 UTC
Created attachment 115043 [details]
bzipped2 stderr.log

While reviewing an issue reported by the dbus coverity scan it looks to be a reference counting issue in test-relay. The test application test-relay opens private connections to a local server and closes/unref them at the end of the test.

Running the test with DBUS_VERBOSE=1 DBUS_CONNECTION_TRACE=1 test-relay 2> stderr.log ; grep trace_ref stderr.log shows at the end connection reference counts of 3 for all 4 present connections. 

3132: [dbus/dbus-internals.c(511):_dbus_trace_ref] DBusConnection 0x143e680 4 -> 3 refs (unref)
3132: [dbus/dbus-internals.c(511):_dbus_trace_ref] DBusConnection 0x143fba0 4 -> 3 refs (unref)
3132: [dbus/dbus-internals.c(511):_dbus_trace_ref] DBusConnection 0x143ef60 4 -> 3 refs (unref)
3132: [dbus/dbus-internals.c(511):_dbus_trace_ref] DBusConnection 0x14404d0 4 -> 3 refs (unref)

The documentation of dbus_connection_open_private mentiones to call dbus_connection_close() and dbus_connection_unref() to free the connection, which is done in the test-relay.
Comment 1 Simon McVittie 2015-04-13 11:16:13 UTC
I wonder whether this would go away if we did

dbus_connection_close (conn);

while (Disconnected message not seen for conn)
  iterate main context;

dbus_connection_unref (conn);

?
Comment 2 Ralf Habacker 2015-04-13 13:08:57 UTC
Created attachment 115057 [details] [review]
Fix 'dbus connection referencing issue in test-relay'.
Comment 3 Ralf Habacker 2015-04-13 13:10:07 UTC
(In reply to Simon McVittie from comment #1)
> I wonder whether this would go away if we did
> 
> dbus_connection_close (conn);
> 
> while (Disconnected message not seen for conn)
>   iterate main context;
> 
> dbus_connection_unref (conn);
> 
> ?

The bug turned out to be an obviously shutdown problem.
Comment 4 Simon McVittie 2015-04-13 13:26:24 UTC
Comment on attachment 115057 [details] [review]
Fix 'dbus connection referencing issue in test-relay'.

Review of attachment 115057 [details] [review]:
-----------------------------------------------------------------

Makes sense, ++
Comment 5 Ralf Habacker 2015-04-13 13:33:11 UTC
Comment on attachment 115057 [details] [review]
Fix 'dbus connection referencing issue in test-relay'.

committed to dbus-1.8
Comment 6 Simon McVittie 2015-04-13 16:26:29 UTC
(In reply to Ralf Habacker from comment #5)
> committed to dbus-1.8

I wouldn't normally commit test fixes like this to dbus-1.8 unless they were blocking its releases (e.g. a test failing or not compiling at all), because it cannot affect library-user code - the goal with stable branches is to make the minimum changes necessary to go from "real-world use is broken" to "real-world use works as expected".

But this change is small enough that I'm not going to revert it either.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.