Bug 42186

Summary: Gabble assumes that the server only replies to its roster query once (!)
Product: Telepathy Reporter: Guillaume Desmottes <guillaume.desmottes>
Component: gabbleAssignee: Will Thompson <will>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium CC: avtarsinghbainsla
Version: unspecifiedKeywords: patch
Hardware: Other   
OS: All   
Whiteboard: review+
i915 platform: i915 features:
Attachments: roster: ignore multiple replies to roster query.

Description Guillaume Desmottes 2011-10-25 00:49:15 UTC
Original bug report: https://bugzilla.gnome.org/show_bug.cgi?id=662469


Reporter hits this assertion:

tp-glib-CRITICAL: 24.10.2011 20:28:09.96050: tp_base_contact_list_set_list_received: assertion `self->priv->state != TP_CONTACT_LIST_STATE_SUCCESS' failed


See https://bugzilla.gnome.org/attachment.cgi?id=199843 for the full log.
Comment 1 Will Thompson 2011-10-28 10:26:42 UTC
From the log, Gabble sends the initial roster query:

wocky-DEBUG: 24.10.2011 20:28:05.884869: _write_node_tree: Serializing tree:
* iq xmlns='jabber:client' type='get' id='360457884838'
    * query xmlns='jabber:iq:roster'

It gets a reply 2 seconds later:

wocky-DEBUG: 24.10.2011 20:28:07.247874: _end_element_ns: Received stanza
* iq xmlns='jabber:client' to='grandmaster@vk.com/37346436' type='result' id='360457884838'
    * query xmlns='jabber:iq:roster'

…and then gets the same reply *again*:

wocky-DEBUG: 24.10.2011 20:28:09.73115: _end_element_ns: Received stanza
* iq xmlns='jabber:client' to='grandmaster@vk.com/37346436' type='result' id='360457884838'
    * query xmlns='jabber:iq:roster'

The issue is that Gabble doesn't use send_iq_async() or something to send the initial request: it just fires off the IQ, and then has a handler which looks for IQs of type 'set' or 'result' which contain <query xmlns='jabber:iq:roster'/>. It never checks that it doesn't get the result twice…
Comment 2 Will Thompson 2011-10-28 10:32:19 UTC
I have tried to report the issue to the vk.com server maintainers using the form at http://vk.com/help.php?page=jabber but it doesn't seem to work.
Comment 3 Will Thompson 2011-10-28 10:38:59 UTC
Created attachment 52863 [details] [review]
roster: ignore multiple replies to roster query.

The XMPP server running on vk.com is buggy, and replies to our roster
query twice. Gabble just blindly assumed that any <iq type='result'>
with a roster in it was the singular reply to our singular query. This
is a pretty reasonable assumption but this buggy server violates it, and
Gabble calls tp_base_contact_list_set_list_received() more than once,
which triggers a critical in that function.

A more invasive fix would use wocky_porter_send_iq_async() rather than
scraping all the roster IQs out of everything using the LM API, but I
wanted to quickly fix a bug on a Friday afternoon.
Comment 4 Jonny Lamb 2011-10-28 12:13:13 UTC
Looks good.
Comment 5 Will Thompson 2011-10-31 02:39:58 UTC
Merged to 0.12 and master; will be in 0.12.8 and 0.13.8.

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.