Bug 19863

Summary: obscure crash closing connection
Product: dbus Reporter: Havoc Pennington <hp>
Component: coreAssignee: Havoc Pennington <hp>
Status: RESOLVED FIXED QA Contact: John (J5) Palmieri <johnp>
Severity: normal    
Priority: medium Keywords: patch
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Havoc Pennington 2009-01-31 17:26:55 UTC
I reproduced a couple times an assertion failure due to removing a not-added timeout in this spot, during dbus_shutdown(). I think the below would fix it. It's a little hard to be sure since it's so hard to reproduce in the first place. The backtrace kind of sucks too because gcc is inlining the heck out of dbus-connection.c

The assertion failure is this one in dbus-timeout.c:

 if (!_dbus_list_remove (&timeout_list->timeouts, timeout))
    _dbus_assert_not_reached ("Nonexistent timeout was removed");

The patch just adds "if is_timeout_added(pending)"

@@ -2188,9 +2199,14 @@ connection_timeout_and_complete_all_pending_calls_unlocked (DBusConnection *conn
        
       _dbus_pending_call_queue_timeout_error_unlocked (pending, 
                                                        connection);
-      _dbus_connection_remove_timeout_unlocked (connection,
-                                                _dbus_pending_call_get_timeout_unlocked (pending));
-      _dbus_pending_call_set_timeout_added_unlocked (pending, FALSE);       
+
+      if (_dbus_pending_call_is_timeout_added_unlocked (pending))
+        {
+          _dbus_connection_remove_timeout_unlocked (connection,
+                                                    _dbus_pending_call_get_timeout_unlocked (pending));
+          _dbus_pending_call_set_timeout_added_unlocked (pending, FALSE);
+        }
+
Comment 1 Simon McVittie 2011-03-03 07:46:51 UTC
Scott James Remnant made an equivalent commit between 1.2.14 and 1.2.16.

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.