pyspotify icon indicating copy to clipboard operation
pyspotify copied to clipboard

Segfault on search when user data for the callback is not given

Open valentindavid opened this issue 15 years ago • 2 comments

When no user data is given for the callback of a search query, then there can happen a segfault. I propose a patch. But it is to be noted that:

  1. If the user does not give a user data parameter, then its callback should not have a parameter for it. But I think it makes sense like that. This is a change in the API, but the users will have their code failing with a nice error telling them there is a parameter too many on their callback.
  2. Looking at the code, there are lots of memory leaks. This is specially a problem for programs which run as daemon. For instance, the two pointers callback and userdata are not decremented for the GC, and the struct containing the pointers is not deallocated. This patch does not address this problem. You should think of using valgrind to hunt those leaks.

I do not know how to attach a file on github: http://www.valentindavid.com/files/pyspotify-master-segfault_on_search.patch

valentindavid avatar Oct 09 '10 00:10 valentindavid

Thanks a lot for your great work Valentin! I have applied your patch and tested it in my pyspotify branch which I use together with the Mopidy project I am working on. Seems to be solving an annoying problem we had with Mopidy segfaulting while searching. The memory leaks should be fixed some time too, but at least this solves our issues temporarily. You are more than welcome to contribute, if you have the time!

Winjer, hope you can merge this patch in to your master. All credits to Valentin!

knutz3n avatar Oct 11 '10 18:10 knutz3n

After several days of testing, I can confirm that this patch stops Mopidy from segfaulting when playing music and searching simultaneously.

Winjer: Could you merge knutz3n/master?

jodal avatar Oct 16 '10 13:10 jodal