c - libspotify crashes with segFault after calling sp_session_create -


i testing out libspotify library (version 12.1.51 x86 linux) , application keeps crashing when call sp_session_create() segmentation fault.

i don't have application key, nor premium spotify account (yet), shouldn't reason crash, since if remember correctly, there error code invalid application key.

my code follows:

static uint_8_t g_appkey[] = {1, 2, 3}; static const char *username = "myusername"; static const char *password = "mypassword"; static int logged_in;  static sp_session_callbacks session_callbacks; static sp_session_config spconfig;  static void on_login(sp_session *session, sp_error error) {     printf("callback: on_login");     if (error != sp_error_ok) {         printf("error: unable login: %d\n", (int) error);         exit(-1);     }     logged_in = 1; }  static void on_main_thread_notified(sp_session *session) {     printf("callback: on_main_thread_notified"); }  static void on_log_message(sp_session *session, const char *data) {     printf("callback: on_log_message"); }  int main(int argc, char **argv) {     sp_error error;     sp_session *session;     int next_timeout;      /* struct fill */     memset(&session_callbacks, 0, sizeof(session_callbacks));     memset(&spconfig, 0, sizeof(spconfig));       session_callbacks.logged_in          = &on_login;     session_callbacks.notify_main_thread = &on_main_thread_notified;     session_callbacks.log_message        = &on_log_message;       spconfig.api_version          = spotify_api_version;     spconfig.cache_location       = "tmp";     spconfig.settings_location    = "tmp";     spconfig.application_key      = g_appkey;     spconfig.application_key_size = sizeof(g_appkey);     spconfig.user_agent           = "spot";     spconfig.callbacks            = &session_callbacks;      /* session creation */       error = sp_session_create(&spconfig, &session);     if (error != sp_error_ok) {         printf("error: unable create spotify session: %s\n", sp_error_message(error));         exit(-1);     }      /* log in */     logged_in = 0;     sp_session_login(session, username, password, 0, null);     while(!logged_in) {         sp_session_process_events(session, &next_timeout);         sleep(next_timeout);     }      printf("sucess!!");     exit(0); } 

any tips problem?

appreciated given.


backtrace gdb:

[thread debugging using libthread_db enabled] [new thread 0xb7fe6b70 (lwp 1839)] [new thread 0xb7f65b70 (lwp 1840)]  program received signal sigsegv, segmentation fault. 0x002b9b36 in sp_session_create () /usr/local/lib/libspotify.so.12 (gdb) thread apply backtrace  thread 3 (thread 0xb7f65b70 (lwp 1840)): #0  0x0012d422 in __kernel_vsyscall () #1  0x003e6ce6 in nanosleep () @ ../sysdeps/unix/syscall-template.s:82 #2  0x0041644c in usleep (useconds=10000) @ ../sysdeps/unix/sysv/linux/usleep.c:33 #3  0x00293581 in ?? () /usr/local/lib/libspotify.so.12 #4  0x00293990 in ?? () /usr/local/lib/libspotify.so.12 #5  0x001d42b7 in ?? () /usr/local/lib/libspotify.so.12 #6  0x004ae96e in start_thread (arg=0xb7f65b70) @ pthread_create.c:300 #7  0x0041ca4e in clone () @ ../sysdeps/unix/sysv/linux/i386/clone.s:130  thread 2 (thread 0xb7fe6b70 (lwp 1839)): #0  0x0012d422 in __kernel_vsyscall () #1  0x004b5245 in sem_wait@@glibc_2.1 () @ ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/sem_wait.s:80 #2  0x002178fa in ?? () /usr/local/lib/libspotify.so.12 #3  0x001d42b7 in ?? () /usr/local/lib/libspotify.so.12 #4  0x004ae96e in start_thread (arg=0xb7fe6b70) @ pthread_create.c:300 #5  0x0041ca4e in clone () @ ../sysdeps/unix/sysv/linux/i386/clone.s:130  thread 1 (thread 0xb7fe78d0 (lwp 1836)): #0  0x002b9b36 in sp_session_create () /usr/local/lib/libspotify.so.12 #1  0x080487d5 in main () (gdb)  

problem solved.

i got valid application key spotify, tested out code , works.

it seems current live libspotify version has bug when entering invalid application keys.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -