Stability of Hallon

12 views
Skip to first unread message

Allan Nørgaard Kristensen

unread,
Feb 15, 2013, 3:53:58 AM2/15/13
to ruby-...@googlegroups.com
Hey Folks

Wondering if I'm the only one having stability problems with this gem? I have build a very simple example, that does nothing but log in to the spotify service and fetch my playlist container and the first playlist. One of several things happens once running.
  1. Program succesfully loads my playlist (~50%)
  2. Segmentation fault (~40%, different types though)
  3. Ruby fails to "convert string to integer" (reported in observable.rb:198)
  4. Ruby Interpreter Crashing
My script looks as the following:

require 'hallon'

session = Hallon::Session.initialize IO.read("./spotify_app.key")
session.login("m...@email.com", "password")

print "[SESSION] Logging in ..."
while(session.status != :logged_in)
session.process_events
print "."
sleep(3)
end
puts " done!"
c = session.container
c.load

while(session.container.loaded? == false)
session.process_events
sleep(0.1)
end
p = c.contents.at(0).load

The segmentation fault can be as simple as the two words mentioned or described a bit, like shown in the below three code markings

Segmentation fault (core dumped)

daemon.rb: [BUG] SEGV received in SEGV handler
Segmentation fault
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

Aborted (core dumped)


daemon.rb: [BUG] Segmentation fault
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0001 p:0000 s:0002 b:0002 l:0019c8 d:0019c8 TOP  


-- C level backtrace information -------------------------------------------

The observable.rb conversion error looks like the following:

/home/allan/.rvm/gems/ruby-1.9.3-p194/gems/hallon-0.18.1/lib/hallon/observable.rb:198:in `[]': can't convert String into Integer (TypeError)
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/hallon-0.18.1/lib/hallon/observable.rb:198:in `trigger'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/hallon-0.18.1/lib/hallon/observable.rb:91:in `block in trigger'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/hallon-0.18.1/lib/hallon/observable.rb:89:in `each'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/hallon-0.18.1/lib/hallon/observable.rb:89:in `inject'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/hallon-0.18.1/lib/hallon/observable.rb:89:in `trigger'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/hallon-0.18.1/lib/hallon/observable/playlist.rb:34:in `tracks_added_callback'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/spotify-12.3.0/lib/spotify.rb:99:in `call'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/spotify-12.3.0/lib/spotify.rb:99:in `session_process_events'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/spotify-12.3.0/lib/spotify.rb:99:in `block in method_missing'
 from /home/allan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/spotify-12.3.0/lib/spotify.rb:98:in `method_missing'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/hallon-0.18.1/lib/hallon/session.rb:168:in `block in process_events'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/hallon-0.18.1/lib/hallon/session.rb:167:in `initialize'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/hallon-0.18.1/lib/hallon/session.rb:167:in `new'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/hallon-0.18.1/lib/hallon/session.rb:167:in `process_events'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/hallon-0.18.1/lib/hallon/loadable.rb:18:in `block in load'
 from /home/allan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:68:in `timeout'
 from /home/allan/.rvm/gems/ruby-1.9.3-p194/gems/hallon-0.18.1/lib/hallon/loadable.rb:16:in `load'
 from daemon2.rb:26:in `<main>'



At other times, the entire ruby interpreter crashes (more errors than can be in the entire terminal buffer!)
The log can be seen at https://sites.google.com/site/dumpscript/ if it is of any interest. 

Am I using the gems incorrectly? Been fiddling with it for several hours with no luck! 

Thanks in advance, 
- Allan

Kim Burgestrand

unread,
Feb 15, 2013, 3:56:22 PM2/15/13
to Hallon on behalf of Allan Nørgaard Kristensen
On OS X (which is my main development platform), Hallon is quite stable. I ran your code successfully
1031 times before Spotify themselves rate limited me so much that the calls timed out.

However, the Linux variant of libspotify is slightly different. The linux release of libspotify is different
from the Mac OS one, and since I don’t develop on Linux there’s the probability of issues existing on
Linux that don’t exist on OSX.

Now, the difference stems from the session configuration on Linux accepting one additional parameter,
the ca_certs_filename option. In order to see if the spotify gem also has this option, you can run this:

ruby -rspotify -e 'p Spotify::SessionConfig.layout.members'

It will print an array of all configuration options that the spotify gem knows about.

However, by far the most common reasons of people having segfaults with Hallon and the spotify gem
is when they use the wrong version of libspotify for a given version of Hallon. Hallon v0.18 will *only*
work properly with libspotify v12.1.51. You can inspect which version of libspotify has been loaded with:

ruby -rspotify -e 'p Spotify.build_id'

If you *are* running v12.1.51, you should also make sure you have the correct library for your CPU.
A 64-bit version of the library won’t work well on a 32-bit CPU.

I also know people on Raspberry PI have had a lot of issues, which were resolved by installing another
OS than the Raspbian distribution.

I don’t know much about your setup, so I’ve listed a bunch of possible reasons. Please check on all
of these!

— Kim

--
You received this message because you are subscribed to the Hallon ruby gem mailing list.

- To view this group online, visit https://groups.google.com/d/forum/ruby-hallon
- To post to this group, send email to ruby-...@googlegroups.com
- To unsubscribe from this group, send email to ruby-hallon...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "Hallon" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-hallon...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Allan Nørgaard Kristensen

unread,
Feb 16, 2013, 8:12:09 AM2/16/13
to ruby-...@googlegroups.com
Hey Kim,

First of all, thanks for the quick reply. 

Maybe I should have included some system details - i'm running an updated linux mint 14 x64, however my target is indeed a raspberry pi once i'm finished. 

I am already running the libspotify 12.1.51 x64, confirmed with the command you provided: "12.1.51.g86c92b43 Release Linux-x86_64"

You lost me, however, on the gem options, but the command returns an array as the following, and the ca_certs_filename is included.  
[:api_version, :cache_location, :settings_location, :application_key, :application_key_size, :user_agent, :callbacks, :userdata, :compress_playlists, :dont_save_metadata_for_playlists, :initially_unload_playlists, :device_id, :proxy, :proxy_username, :proxy_password, :ca_certs_filename, :tracefile]

I should probably mention that the problems arise only when i'm using my "own" playlist container (i.e. the one I retrieve from the session) - playing audio, creating track objects etc. works just fine. 
I guess I will try to see if I can avoid using the playlist container, and see if that is the only problem in the linux version :-)

--Allan

Kim Burgestrand

unread,
Feb 19, 2013, 2:59:22 PM2/19/13
to Hallon on behalf of Allan Nørgaard Kristensen
Peculiar. I would not expect it to be broken at all in Linux, apart from possibly the session configuration
thing, but I would expect that to break all of the application and not just a tiny subset.

I’m afraid I don’t know what to do about your particular issue, or even where to begin trying to track it. Perhaps
I could use some 64-bit VM of Linux some time, and try to reproduce it.

One thing *you* could try is clearing out your cache used by Hallon. Old and corrupted cache can play very
weird with libspotify, including causing segfaults when using certain features. I’ve had it happen in the past to
both myself and others.

— Kim

Bradley Jones

unread,
Feb 23, 2013, 5:54:37 PM2/23/13
to ruby-...@googlegroups.com
Trying to run this code under OSx works fine for me however running it under linux (either on Raspberry Pi or a VM) never sees the session playlist container loaded 

it just hangs here: 
c = session.container
c.load

Any suggestions not sure if you managed to solve this

Allan Nørgaard Kristensen

unread,
Feb 23, 2013, 6:13:44 PM2/23/13
to ruby-...@googlegroups.com
@Kim I tried that already, without any noticeable effect :-\

@Bradley Yep that seems to be the spot, where it gets sticky. Sometimes it loads perfectly, while it crashes at others. I started having problems with track objects as well, after calling that code even when the playlist succeeded. I wasn't able to solve it, and had to turn back to use C and libspotify directly instead, but please post if you find any news on the linux/raspberry front

--Allan

Kim Burgestrand

unread,
Feb 24, 2013, 9:03:25 AM2/24/13
to Hallon on behalf of Allan Nørgaard Kristensen
I’ve experimented some on my raspberry pi (soft float raspbian OS) with the raw spotify
API, using only Ruby FFI for a ruby test, and an equivalent C example.

Running the C code never causes a crash, while running the Ruby FFI one will cause some
memory corruption. I’m not quite sure why this is, but I suspect Ruby FFI have something
to do with it. I’ll ask on their mailing list and see what I can dig up.

I don’t have access to a non-raspberry pi linux box, so I can’t run the tests on a regular
(non-arm) processor.


— Kim

Aurélien Malisart

unread,
Feb 28, 2013, 11:05:42 AM2/28/13
to ruby-...@googlegroups.com
Hi,

I also encounter issues with never-finishing requests here :-/  Not sure if it's related to linux.

Aurels

Kim Burgestrand

unread,
Feb 28, 2013, 11:10:19 AM2/28/13
to Hallon on behalf of Aurélien Malisart
libspotify is like that at times. It is not uncommon at all, and not specific to operating system.
--
You received this message because you are subscribed to the Hallon ruby gem mailing list.

- To view this group online, visit https://groups.google.com/d/forum/ruby-hallon
- To post to this group, send email to ruby-...@googlegroups.com
- To unsubscribe from this group, send email to ruby-hallon...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "Hallon" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-hallon...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
Kim Burgestrand

Kim Burgestrand

unread,
Feb 28, 2013, 5:06:50 PM2/28/13
to Hallon on behalf of Aurélien Malisart
An update on the segfaulting issues: I’ve managed to reproduce the crashes in libspotify with
valid C code, which leads me to believe there are issues in libspotify that are more apparent when
using the library in a certain way (used in ruby ffi), but not another (in typical c code).

Unfortunately, because of the way the spotify gem interact with the libspotify library, it’s tricky
to work around (if it’s even possible), assuming the problem is with libspotify.

This applies only to ARM platforms (i.e. raspberry pi). Have not had time to try it out on x86 linux yet.

— Kim
Reply all
Reply to author
Forward
0 new messages