New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sporadic crash during iterative search queries #121

Closed
liamw9534 opened this Issue Mar 14, 2014 · 3 comments

Comments

2 participants
@liamw9534

liamw9534 commented Mar 14, 2014

Seeing the following crash in the python wrapper from an application I have written that is performing a number of iterative search queries:

From callback <function _search_complete_callback at 0x103ad70>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/spotify/search.py", line 308, in _search_complete_callback
    search_result._callback_handles.remove(handle)
AttributeError: '_cffi_backend.CData' object has no attribute '_callback_handles'

I took a look at the code and couldn't see an obvious way by which the class could be initialized without the _callback_handles attribute being assigned i.e., it gets assigned to an empty set on line 52.

However, I do wonder if there is a possibility that an invalid handle could be returned by the C library in the following code fragment:

   (callback, search_result) = ffi.from_handle(handle)

Any thoughts on this would be appreciated.

@jodal jodal added 2.x labels Mar 14, 2014

@jodal jodal self-assigned this Mar 14, 2014

@jodal jodal added this to the v2.0.0a2 milestone Mar 14, 2014

@liamw9534

This comment has been minimized.

liamw9534 commented Mar 14, 2014

Ok, I'd like to close this issue. It is a bug in my code which causes the search object to be unreferenced in certain code paths causing the GC to remove the object which is subsequently referenced by the search.py callback routine.

@liamw9534 liamw9534 closed this Mar 14, 2014

@jodal

This comment has been minimized.

Member

jodal commented Mar 14, 2014

I was suspecting this could happen, as you can see from some of my remaining TODOs, ref. https://github.com/mopidy/pyspotify/blob/v2.x/develop/spotify/search.py#L57-L59. I'll leave this open until I've tried to address it and make this safe.

@jodal jodal reopened this Mar 14, 2014

@liamw9534

This comment has been minimized.

liamw9534 commented Mar 14, 2014

Yes, I saw that. Thanks for the reply. Basically, in this instance, my search timed out and the search object was no longer being referenced. I think it's an easy fix, by the way, just to add a try/except around the code in the callback routine, which tries to remove the callback handle from the set, and just ride the exception out.

@jodal jodal closed this in f9834c0 Mar 25, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment