4

I've been messing around with libspotify for a while now but I get a segmentation fault every once in a while when I call the sp_session_logout() API.

I did a test that does the following loop:

  • Create a session
  • Login
  • Logout
  • Release the session

It usually crashes after 3-4 iterations.

The code and the stdout can be found here: https://gist.github.com/jonas-lundqvist/4bb759a1f1ed09de46a1

Compiled with:

gcc -std=gnu99 -g -Wall `pkg-config --cflags libspotify` -o test_login_logout login_logout.c appkey.c cred.c -lpthread `pkg-config --libs libspotify`

I noticed however that two threads was created in the start of each iteration, but only one exited.

This is the output from gdb

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff7fbf700 (LWP 31308)]
[New Thread 0x7ffff7f3e700 (LWP 31309)]
[Thread 0x7ffff7f3e700 (LWP 31309) exited]
[New Thread 0x7ffff7f3e700 (LWP 31310)]
[New Thread 0x7ffff7ebd700 (LWP 31311)]
[Thread 0x7ffff7ebd700 (LWP 31311) exited]
[New Thread 0x7ffff7ebd700 (LWP 31313)]
[New Thread 0x7ffff6638700 (LWP 31314)]
[Thread 0x7ffff6638700 (LWP 31314) exited]
[New Thread 0x7ffff6638700 (LWP 31315)]
[New Thread 0x7ffff65b7700 (LWP 31316)]

Program received signal SIGSEGV, Segmentation fault.

Inspecting the threads I can see:

Id   Target Id         Frame
9    Thread 0x7ffff65b7700 (LWP 31316) "Network Thread" 0x00007ffff744b50d in poll () at ../sysdeps/unix/syscall-template.S:81
8    Thread 0x7ffff6638700 (LWP 31315) "Dns Thread" 0x00007ffff744b50d in poll () at ../sysdeps/unix/syscall-template.S:81
6    Thread 0x7ffff7ebd700 (LWP 31313) "Dns Thread" sem_wait ()
at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85
4    Thread 0x7ffff7f3e700 (LWP 31310) "Dns Thread" sem_wait ()
at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85
2    Thread 0x7ffff7fbf700 (LWP 31308) "Dns Thread" sem_wait ()
at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85
* 1    Thread 0x7ffff7fc1700 (LWP 31304) "test_login_logo" 0x00007ffff77eb5ac in ?? () from /home/jonas/lib/libspotify/lib/libspotify.so.12

And if I pick on of the threds created in one of the iterations I can see this:

[Switching to thread 4 (Thread 0x7ffff7f3e700 (LWP 31310))]
#0  sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85
85  ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S: No such file or directory.
#0  sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:85
#1  0x00007ffff780c1f8 in ?? () from /home/jonas/lib/libspotify/lib/libspotify.so.12
#2  0x00007ffff77c608d in ?? () from /home/jonas/lib/libspotify/lib/libspotify.so.12
#3  0x00007ffff7bc70a4 in start_thread (arg=0x7ffff7f3e700) at pthread_create.c:309
#4  0x00007ffff745404d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Unfortunatley the libspotify development seems quite dead, but does anybody know if there is a work around?

I need to be able to do multiple sp_session_create()/sp_session_release() in my application...

Edit: bt of the crashing thread (from another, yet similar, run)

#0  0x00007ffff77eb5ac in ?? () from /home/jonas/lib/libspotify/lib/libspotify.so.12
#1  0x00007ffff7860b5a in ?? () from /home/jonas/lib/libspotify/lib/libspotify.so.12
#2  0x00007ffff781683f in ?? () from /home/jonas/lib/libspotify/lib/libspotify.so.12
#3  0x00007ffff7817141 in ?? () from /home/jonas/lib/libspotify/lib/libspotify.so.12
#4  0x00007ffff78add7d in sp_session_logout () from /home/jonas/lib/libspotify/lib/libspotify.so.12
#5  0x0000000000400d51 in main (argc=1, argv=0x7fffffffe3a8) at login_logout.c:99
rav_kr
  • 434
  • 8
  • 16
  • Why aren't you using the new SDK; both Android and iOS are in active development. The libSpotify project has been out of development for around 2 years. – brad J May 04 '15 at 01:59
  • 3
    @user2369063 If there was a new SDK that replaces libspotify I would of course use it. But since my application is neither for Android nor iOS those aren't an option. – Jonas Lundqvist May 04 '15 at 09:06

0 Answers0