1

For some users, the libspotify crashes when calling sp_session_create.

All config parameters are set except the proxy settings which are NULL.

The crash occurs at libspotify+0xdc7c0

I have minidumps available.

JBL
  • 129
  • 8
  • I am experiencing exactly this on Windows 8. It does not happen when run on older Windows releases. – paddy May 06 '14 at 06:20

1 Answers1

0

I have found this to be a permissions issue. If the user does not have permissions to create (and/or modify) the settings and cache directories passed to sp_session_create, it will helpfully crash. I think that a helpful error code with no crash would have saved me an awful lot of time.

The solution is to make sure the settings and cache directories can be created (if they do not exist) and that they are writable by the current user. This could be achieved either by directly modifying directory permissions or by changing the location of those directories to somewhere else (eg the user's AppData directory).

I should mention that I use the same directory for both (in case that wasn't already obvious), and I haven't bothered to isolate which is responsible for the crash.

Anyway, on Windows 8 this was a problem when a program was installed under the Program Files directory and my settings/cache was a relative path off that. The users by default did not have sufficient privileges.

Hope this helps.

paddy
  • 60,864
  • 6
  • 61
  • 103
  • I'm already setting the cache directory and all the other paths to the user's AppData directory. Do you think the permission issue could also occur in the AppData directory? – JBL May 07 '14 at 08:13
  • If you're able to reproduce the crash yourself, you'll be able to experiment. This fixed the issue for me, and yes I ended up creating something in the AppData directory. – paddy May 07 '14 at 08:18
  • @JBL Just a thought... Are you specifying your own directory inside AppData? Does it exist, or do you expect libspotify to create it? `sp_session_create` will create the cache directory if it doesn't exist, but the settings directory must exist already. In both cases, the directory must be writable. I have ended up just touching a file in my cache/settings dir first, in case permissions have changed. Funnily enough, there is an error code `SP_ERROR_API_INITIALIZATION_FAILED` to indicate something is wrong, but the function crashes instead of returning it. – paddy May 08 '14 at 04:27
  • I'm not able to reproduce the crash myself, but I added a check to prevent the initialization of libspotify (the libspotify is optional in my application) if the permissions are not right. No more crash reports so far. Thanks for your help! – JBL May 08 '14 at 09:14