0

So this particular libspotify error has me a little stumped. My app basically loads a users playlists, and allows users to go into those playlists at which time it populates the track data.

So the problem lies in the function:

sp_image* image = sp_image_create(session, image_id);

(after calling) const byte* image_id = sp_album_cover(album, SP_IMAGE_SIZE_SMALL);

Now this works fine some of the time, but quite often it will pop up with a 'Corrupt memory passed to dlfree(), SIGSEGV' error, which cause. So first thing I looked for is a memory error but theres plenty of free memory and there are no null pointers when this occurs. The call occurs from with the library to libc.so so its much deeper into the library than i can access.

It obviously has something to do with memory but its odd that it could happen after loading 10 tracks or after 400 tracks and stranger yet, from my testing devices, it only happens on the Nexus 4 and Nexus 7 and not on the Galaxy S3, or HTC sensation. First thing that springs to mind is the fact that the N4 & N7 are Qualcomm devices but thats all i have to go on, and probably has nothing to do with anything!

Any help is much appreciated!

James
  • 93
  • 1
  • 1
  • 5
  • to be exact the error is: 04-11 16:46:20.957: A/libc(4599): invalid address or address of corrupt block 0x6a031770 passed to dlfree 04-11 16:46:20.957: A/libc(4599): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 4631 (Network Thread) – James Apr 11 '14 at 15:46
  • That's not a lot to go on, but I'd guess it might be either a use-after-free or a threading bug. Check that you have the right number of add_refs and releases, and that you never call spotify functions concurrently on different threads. – Weeble Apr 11 '14 at 16:55
  • Yeah I've got a decent handle on the reference releasing so i know im fine for that. I only call spotify functions off a single thread so i'm confident about that too. Kind of running out of ideas! The only thing I have found is that the size variable that comes out of sp_image_data(image, &size); is huge just before it crashes and I think within the library it is trying to free nonsense memory, and I've no way of stopping it. Thats just a shot in the dark however. – James Apr 14 '14 at 09:29

1 Answers1

1

It's probably libspotify's fault, not yours. This library has never been particularly stable on Android (in fact, Spotify still calls it "beta"), however they will be replacing it soon with a new library similar to the Spotify iOS SDK.

My advice to you would be to not use libspotify unless you are under pressure to ship something right away. The new SDK will likely solve many of the headaches familiar to developers working with libspotify on Android.

Edit: The new Spotify Android SDK is out! You should use it instead of libspotify, it will save you much headache.

Nik Reiman
  • 39,067
  • 29
  • 104
  • 160
  • Hi nik, yeah i've come to that conclusion myself simply because i've covered every possible problem in my spotify wrapper about a thousand times. Do you have any more info on an ETA with that new library. Also do you know if it would keep the same type of function calls/order etc. or is it just a completely new way of doing things? Thanks for your help – James Jun 25 '14 at 08:28
  • @James it was released on Wednesday! See my edit above. – Nik Reiman Jun 27 '14 at 07:48