Bug 27553

Summary: telepathy-butterfly crashed with InvalidHandle in check_handle()
Product: Telepathy Reporter: Sebastien Bacher <seb128>
Component: butterflyAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED FIXED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium CC: caravena
Version: unspecifiedKeywords: patch
Hardware: Other   
OS: All   
URL: http://git.collabora.co.uk/?p=user/jonny/telepathy-butterfly.git;a=shortlog;h=refs/heads/27553
Whiteboard: review+
i915 platform: i915 features:
Attachments: butterfly.log
debbug2-butterfly.log

Description Sebastien Bacher 2010-04-09 06:20:41 UTC
The bug has been opened on https://bugs.launchpad.net/ubuntu/+source/telepathy-butterfly/+bug/512596 and has some duplicates there

The descriptions seems to indicate it happens when adding a buddy

Stacktrace on 0.5.7

"Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/papyon/client.py", line 446, in event
    self._dispatch(method_name, *event_args)
  File "/usr/lib/pymodules/python2.6/papyon/event/__init__.py", line 44, in _dispatch
    if event_handler._dispatch_event(name, *args):
  File "/usr/lib/pymodules/python2.6/papyon/event/__init__.py", line 65, in _dispatch_event
    handler(*params)
  File "/usr/lib/python2.6/dist-packages/butterfly/channel/group.py", line 122, in on_addressbook_group_added
    self.AddMembers(self.__pending_add, None)
  File "/usr/lib/python2.6/dist-packages/butterfly/channel/group.py", line 71, in AddMembers
    contact_handle_id)
  File "/usr/lib/python2.6/dist-packages/butterfly/connection.py", line 139, in handle
    self.check_handle(handle_type, handle_id)
  File "/usr/lib/python2.6/dist-packages/telepathy/server/conn.py", line 154, in check_handle
    (handle, handle_type))
InvalidHandle: org.freedesktop.Telepathy.Error.InvalidHandle: handle number 18 not valid for type 1"


Other stacktraces:
http://launchpadlibrarian.net/38384257/Traceback.txt
http://launchpadlibrarian.net/40823588/Traceback.txt
Comment 1 Cristian Aravena 2010-04-24 20:04:06 UTC
*** Bug 27829 has been marked as a duplicate of this bug. ***
Comment 2 Jonny Lamb 2010-04-25 02:21:14 UTC
Odd. Can I get some butterfly logs please?
Comment 3 Cristian Aravena 2010-04-25 11:01:43 UTC
Created attachment 35280 [details]
butterfly.log

bug with space. " example@correo.cl"
Comment 4 Cristian Aravena 2010-04-25 11:07:41 UTC
Created attachment 35283 [details]
debbug2-butterfly.log

Bug add user with spache in the end. "example@correo.cl "
Comment 5 Jonny Lamb 2010-04-25 13:05:22 UTC
Okay what's happening here is Empathy is calling RequestHandles for the contact you are trying to add, and then the contact list channel waits for the mutex to become unlocked before progressing.

In the mean time, Empathy calls ReleaseHandles on the handle which was just requested. This means that the contact handle object gets disposed and gets lost from the Connection._handles dict. When the mutex unlocked callback gets called, it can't find the object, hence the traceback.

However, if you try to add a contact which actually exists (i.e. not foo@example.com), then it kind of works, which is odd. It requests the handle of the contact, does something, then the callback gets called and the ReleaseHandles has already been called so it can't find the handle. However, papyon calls a callback with this new contact and a brand new handle appears out of the blue.

I've not got time to look into this more right now, but I thought I'd write down what I know for now. We could use this as an excuse to push butterfly into the future of having connection-persistent handles?
Comment 6 Jonny Lamb 2010-04-27 15:42:30 UTC
Okay, so my diagnosis in comment #5 wasn't entirely correct. I was getting confused between the publish and subscribe lists.

I've written a patch which should solve this. There's a big comment in the patch which should explain my reasoning. Testing adding new valid and invalid contacts appears to show this patch works as expected.
Comment 7 Jonny Lamb 2010-04-27 15:46:33 UTC
Better ideas of how to keep handle in scope until after finished_cb() are welcome. You can demonstrate that this scope hack works because if you try to add a bogus contact "boguscontact@example.com", watch it fail, then try RequestHandles on "boguscontact@example.com" gives you a new contact, which is cool.
Comment 8 Jonny Lamb 2010-04-28 23:42:26 UTC
*** Bug 27879 has been marked as a duplicate of this bug. ***
Comment 9 Jonny Lamb 2010-05-01 16:04:32 UTC
*** Bug 27907 has been marked as a duplicate of this bug. ***
Comment 10 Olivier Le Thanh Duong 2010-05-21 06:56:59 UTC
Merged, this fix is available in butterfly 0.5.10
Comment 11 Jonny Lamb 2010-05-26 17:50:19 UTC
*** Bug 28122 has been marked as a duplicate of this bug. ***

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.