Maxing out recursion limit when loading playlist #122

Closed
durden opened this Issue Mar 16, 2014 · 5 comments

Projects

None yet

4 participants

@durden
durden commented Mar 16, 2014

I'm using 2.0.0a1 and getting runtime errors due to too much recursion. It looks like it might be related to some faulty error handing with malloc(). I'm just guessing based on the traceback.

I'm running 10.9 and Python 2.7.3 and trying the following code:

import spotify
def login(session, name, pwd):
    """Block until login is sucessful"""

    import threading

    logged_in_event = threading.Event()

    def logged_in_listener(session, error_type):
        logged_in_event.set()

    session.login(name, pwd)

    session.on(spotify.SessionEvent.LOGGED_IN, logged_in_listener)
    while not logged_in_event.wait(0.1):
        session.process_events()


session = spotify.Session()
login(session, username, password)
pl = spotify.Playlist('spotify:user:durden20:playlist:1chOHrXPCFcShCwB357MFX')
pl.load()

The referenced playlist only has 11 tracks. So, I'm guessing this isn't a memory issue, but again that's just a guess.

This results in the following traceback:

From callback <function playlist_update_in_progress at 0x10b003848>:
Traceback (most recent call last):
  File "/Users/durden/.virtualenvs/spotify_tools/lib/python2.7/site-packages/spotify/playlist.py", line 629, in playlist_update_in_progress
    playlist = Playlist._cached(sp_playlist, add_ref=True)
  File "/Users/durden/.virtualenvs/spotify_tools/lib/python2.7/site-packages/spotify/playlist.py", line 53, in _cached
    playlist = Playlist(sp_playlist=sp_playlist, add_ref=add_ref)
  File "/Users/durden/.virtualenvs/spotify_tools/lib/python2.7/site-packages/spotify/playlist.py", line 69, in __init__
    lib.sp_playlist_add_ref(sp_playlist)
  File "/Users/durden/.virtualenvs/spotify_tools/lib/python2.7/site-packages/spotify/__init__.py", line 43, in wrapper
    with _lock:
RuntimeError: maximum recursion depth exceeded while calling a Python object
From callback <function playlist_update_in_progress at 0x10b003848>:
Traceback (most recent call last):
  File "/Users/durden/.virtualenvs/spotify_tools/lib/python2.7/site-packages/spotify/playlist.py", line 629, in playlist_update_in_progress
    playlist = Playlist._cached(sp_playlist, add_ref=True)
  File "/Users/durden/.virtualenvs/spotify_tools/lib/python2.7/site-packages/spotify/playlist.py", line 53, in _cached
    playlist = Playlist(sp_playlist=sp_playlist, add_ref=add_ref)
  File "/Users/durden/.virtualenvs/spotify_tools/lib/python2.7/site-packages/spotify/playlist.py", line 69, in __init__
    lib.sp_playlist_add_ref(sp_playlist)
  File "/Users/durden/.virtualenvs/spotify_tools/lib/python2.7/site-packages/spotify/__init__.py", line 43, in wrapper
    with _lock:
  File "/usr/local/Cellar/python/2.7.3/lib/python2.7/threading.py", line 125, in acquire
    self._note("%s.acquire(%s): recursive success", self, blocking)
RuntimeError: maximum recursion depth exceeded
From callback <function playlist_update_in_progress at 0x10b003848>:
Traceback (most recent call last):
  File "/Users/durden/.virtualenvs/spotify_tools/lib/python2.7/site-packages/spotify/playlist.py", line 629, in playlist_update_in_progress
    playlist = Playlist._cached(sp_playlist, add_ref=True)
  File "/Users/durden/.virtualenvs/spotify_tools/lib/python2.7/site-packages/spotify/playlist.py", line 51, in _cached
    if sp_playlist in spotify.session_instance._cache:
RuntimeError: maximum recursion depth exceeded
From callback <function playlist_update_in_progress at 0x10b003848>:
Traceback (most recent call last):
  File "/Users/durden/.virtualenvs/spotify_tools/lib/python2.7/site-packages/spotify/playlist.py", line 629, in playlist_update_in_progress
    playlist = Playlist._cached(sp_playlist, add_ref=True)
  File "/Users/durden/.virtualenvs/spotify_tools/lib/python2.7/site-packages/spotify/playlist.py", line 53, in _cached
    playlist = Playlist(sp_playlist=sp_playlist, add_ref=add_ref)
  File "/Users/durden/.virtualenvs/spotify_tools/lib/python2.7/site-packages/spotify/playlist.py", line 58, in __init__
    super(Playlist, self).__init__()
RuntimeError: maximum recursion depth exceeded while calling a Python object
python(10125,0x7fff7dcc2310) malloc: *** error for object 0x7fe1b2d730a0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
@jodal
Member
jodal commented Mar 20, 2014

Thanks for you report Luke. Just wanted to tell you that I can reproduce the bug.

@jodal jodal added 2.x bug labels Mar 20, 2014
@jodal jodal added this to the v2.0.0a2 milestone Mar 20, 2014
@jodal jodal self-assigned this Mar 20, 2014
@durden
durden commented Mar 20, 2014

Thanks for the update. Let me know if there's anyway I can help you debug the issue.

@jodal
Member
jodal commented Mar 25, 2014

If you want an immediate workaround, disable the playlist_update_in_progress callback by commenting out this line: https://github.com/mopidy/pyspotify/blob/v2.0.0a1/spotify/playlist.py#L567

I'll find a better solution for beta 1.

@thisiskevinchoi

Can't seem to load a playlist even with the workaround - it's hanging indefinitely on playlist.load() :(

@jodal jodal closed this in 92772cf Apr 19, 2014
@we4sz
we4sz commented Aug 20, 2014

I get this error when i do the session,get_published_playlists() call, any ideas?

From callback <function playlist_update_in_progress at 0xb6832a74>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/playlist.py", line 645, in playlist_update_in_progress
    spotify._session_instance, sp_playlist, add_ref=True)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/__init__.py", line 58, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/playlist.py", line 46, in _cached
    playlist = Playlist(session, sp_playlist=sp_playlist, add_ref=add_ref)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/playlist.py", line 67, in __init__
    lib.sp_playlist_add_ref(sp_playlist)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/__init__.py", line 57, in wrapper
    with _lock:
  File "/usr/lib/python2.7/threading.py", line 171, in acquire
    self._note("%s.acquire(%s): recursive success", self, blocking)
RuntimeError: maximum recursion depth exceeded
From callback <function playlist_update_in_progress at 0xb6832a74>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/playlist.py", line 645, in playlist_update_in_progress
    spotify._session_instance, sp_playlist, add_ref=True)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/__init__.py", line 58, in wrapper
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/threading.py", line 215, in __exit__
    self.release()
  File "/usr/lib/python2.7/threading.py", line 212, in release
    self._note("%s.release(): non-final release", self)
RuntimeError: maximum recursion depth exceeded
From callback <function playlist_update_in_progress at 0xb6832a74>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/playlist.py", line 645, in playlist_update_in_progress
    spotify._session_instance, sp_playlist, add_ref=True)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/__init__.py", line 58, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/playlist.py", line 46, in _cached
    playlist = Playlist(session, sp_playlist=sp_playlist, add_ref=add_ref)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/playlist.py", line 67, in __init__
    lib.sp_playlist_add_ref(sp_playlist)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/__init__.py", line 57, in wrapper
    with _lock:
RuntimeError: maximum recursion depth exceeded while calling a Python object
From callback <function playlist_update_in_progress at 0xb6832a74>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/playlist.py", line 645, in playlist_update_in_progress
    spotify._session_instance, sp_playlist, add_ref=True)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/__init__.py", line 58, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/playlist.py", line 46, in _cached
    playlist = Playlist(session, sp_playlist=sp_playlist, add_ref=add_ref)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/playlist.py", line 67, in __init__
    lib.sp_playlist_add_ref(sp_playlist)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/__init__.py", line 57, in wrapper
    with _lock:
RuntimeError: maximum recursion depth exceeded while calling a Python object
From callback <function playlist_update_in_progress at 0xb6832a74>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/playlist.py", line 645, in playlist_update_in_progress
    spotify._session_instance, sp_playlist, add_ref=True)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/__init__.py", line 57, in wrapper
    with _lock:
RuntimeError: maximum recursion depth exceeded
From callback <function playlist_update_in_progress at 0xb6832a74>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/playlist.py", line 645, in playlist_update_in_progress
    spotify._session_instance, sp_playlist, add_ref=True)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/__init__.py", line 58, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/playlist.py", line 46, in _cached
    playlist = Playlist(session, sp_playlist=sp_playlist, add_ref=add_ref)
  File "/usr/local/lib/python2.7/dist-packages/pyspotify-2.0.0b4-py2.7-linux-i686.egg/spotify/playlist.py", line 51, in __init__
    super(Playlist, self).__init__()
RuntimeError: maximum recursion depth exceeded while calling a Python object
Segmentation fault (core dumped)
@jodal jodal added a commit that referenced this issue Jul 17, 2015
@jodal jodal playlist: Register callbacks iff there is an event listener
Hopefully, this will remove the precondition for bug #122, #153, and #165.
e06b96a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment