Max recursion level exceeded by playlist_update_in_progress callback #165

Closed
DavisNT opened this Issue Jun 22, 2015 · 14 comments

Projects

None yet

3 participants

@DavisNT
DavisNT commented Jun 22, 2015

When using pyspotify==2.0.0 with Mopidy==1.0.5 and Mopidy-Spotify==2.0.0 (commit 70f27932cb in develop) Mopidy crashes after some time with stacktrace:

From cffi callback <function playlist_update_in_progress at 0x383acb0>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/spotify/playlist.py", line 647, in playlist_update_in_progress
    spotify._session_instance, sp_playlist, add_ref=True)
  File "/usr/local/lib/python2.7/dist-packages/spotify/__init__.py", line 58, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/spotify/playlist.py", line 47, in _cached
    playlist = Playlist(session, sp_playlist=sp_playlist, add_ref=add_ref)
  File "/usr/local/lib/python2.7/dist-packages/spotify/playlist.py", line 68, in __init__
    lib.sp_playlist_add_ref(sp_playlist)
  File "/usr/local/lib/python2.7/dist-packages/spotify/__init__.py", line 57, in wrapper
    with _lock:
  File "/usr/lib/python2.7/threading.py", line 126, in acquire
    self._note("%s.acquire(%s): recursive success", self, blocking)
RuntimeError: maximum recursion depth exceeded
From cffi callback <function playlist_update_in_progress at 0x383acb0>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/spotify/playlist.py", line 647, in playlist_update_in_progress
    spotify._session_instance, sp_playlist, add_ref=True)
  File "/usr/local/lib/python2.7/dist-packages/spotify/__init__.py", line 58, in wrapper
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/threading.py", line 155, in __exit__
    self.release()
  File "/usr/lib/python2.7/threading.py", line 152, in release
    self._note("%s.release(): non-final release", self)
RuntimeError: maximum recursion depth exceeded
From cffi callback <function playlist_update_in_progress at 0x383acb0>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/spotify/playlist.py", line 647, in playlist_update_in_progress
    spotify._session_instance, sp_playlist, add_ref=True)
  File "/usr/local/lib/python2.7/dist-packages/spotify/__init__.py", line 58, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/spotify/playlist.py", line 47, in _cached
    playlist = Playlist(session, sp_playlist=sp_playlist, add_ref=add_ref)
  File "/usr/local/lib/python2.7/dist-packages/spotify/playlist.py", line 68, in __init__
    lib.sp_playlist_add_ref(sp_playlist)
  File "/usr/local/lib/python2.7/dist-packages/spotify/__init__.py", line 57, in wrapper
    with _lock:
RuntimeError: maximum recursion depth exceeded while calling a Python object
*** glibc detected *** /usr/bin/python: double free or corruption (!prev): 0x07234860 ***

The problem occurred after playing Spotify and local tracks on Mopidy and afterwards stopping playback and leaving Mopidy running for some hours. This was observed several times ("randomly" without trying to reproduce the issue or understand what caused it). This was the first time this issue happened after enabling logging of Mopidy stdout/stderr to file (the exception/stacktrace is not written to Mopidy logfile). This happened on Raspbian (Raspberry Pi model B).

@jodal
Member
jodal commented Jun 22, 2015

This looks like the same issue as in #122 and #153 surfacing again. If someone can narrow down how to reproduce this consistently I'll hopefully be able to fix it.

@jodal jodal added the bug label Jun 22, 2015
@jodal jodal changed the title from Creashes Mopidy when left unattended for a while to Max recursion level exceeded by playlist_update_in_progress callback Jun 22, 2015
@jodal
Member
jodal commented Jun 26, 2015

This is potentially fixed by 5a6470d. Are you able to test with it? pip install pyspotify==dev should install a version with that fix.

@DavisNT
DavisNT commented Jun 26, 2015

Thank you very much! 👍

I have installed latest Mopidy-Spotify and pyspotify develop versions by:

pip install -U https://github.com/mopidy/mopidy-spotify/archive/develop.zip
pip install -U https://github.com/mopidy/pyspotify/archive/v2.x/develop.zip

pip install -U pyspotify==dev had failed for me. I have updated other Python packages to their latest PyPI published versions as well (Mopidy-1.0.7 Mopidy-Dirble-1.1.2 cachetools-1.0.3 humanfriendly-1.29 pyasn1-0.1.8 pyasn1-modules-0.0.6 pyspotify-2.0.0 setuptools-18.0.1).

I will keep Mopidy running for a few days and let you know.
Previously when trying Mopidy-Spotify-2.0.0 and pyspotify -2.0.0 Mopidy crashed within a day.

@jodal
Member
jodal commented Jun 26, 2015

We managed to reproduce the issue with this fix in place too. The hunt
continues ☺

On Fri, Jun 26, 2015, 23:01 Dāvis Mošenkovs notifications@github.com
wrote:

Thank you very much! [image: 👍]

I have installed latest Mopidy-Spotify and pyspotify develop versions by:

pip install -U https://github.com/mopidy/mopidy-spotify/archive/develop.zip
pip install -U https://github.com/mopidy/pyspotify/archive/v2.x/develop.zip

pip install -U pyspotify==dev had failed for me. I have updated other
Python packages to their latest PyPI published versions as well
(Mopidy-1.0.7 Mopidy-Dirble-1.1.2 cachetools-1.0.3 humanfriendly-1.29
pyasn1-0.1.8 pyasn1-modules-0.0.6 pyspotify-2.0.0 setuptools-18.0.1).

I will keep Mopidy running for a few days and let you know.
Previously when trying Mopidy-Spotify 2.0.0 and pyspotify 2.0.0 Mopidy
crashed within a day.


Reply to this email directly or view it on GitHub
#165 (comment).

@DavisNT
DavisNT commented Jul 12, 2015

Couldn't there be a bug in libspotify - calling playlist_update_in_progress() callback from sp_playlist_add_ref() if it is called while processing this callback?

@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
@jodal
Member
jodal commented Jul 17, 2015

I believe commit e06b96a might have fixed this. Please comment if this is not true, and this should be reopened.

@jodal jodal closed this Jul 17, 2015
@jodal jodal self-assigned this Jul 17, 2015
@DavisNT
DavisNT commented Jul 17, 2015

Thank you very much! I will test this and let you know!

@DavisNT
DavisNT commented Jul 22, 2015

I have experienced some Mopidy crashed while using commit e06b96a. Those crashes did not write anything in stdout/stderr or mopidy.log.
Now I will update to pyspotify==2.0.1 and latest Mopidy-Spotify commit and continue testing.

@kingosticks
Member

I don't see this particular max recursion error any more. I do still get segmentation faults during startup but they may be due to something else.

EDIT: although this one looks related to the recent fix. And this new scary looking one.

@DavisNT
DavisNT commented Jul 30, 2015

I still get Mopidy crashes without anything written to stdout/stderr or Mopidy logs. I will enable core dumps to get some details.

@jodal
Member
jodal commented Jul 30, 2015

Yeah, ditto. It seems like the max recursion issue is gone, but we have at least one other segfault that we all three have experienced now.

@kingosticks
Member

I get two different ones. One related to starred playlists when my
webclient fetches the list of playlists and one when stopping mopidy and it
tries to log out.
On 30 Jul 2015 09:33, "Stein Magnus Jodal" notifications@github.com wrote:

Yeah, ditto. It seems like the max recursion issue is gone, but we have at
least one other segfault that we all three have experienced now.


Reply to this email directly or view it on GitHub
#165 (comment).

@jodal
Member
jodal commented Jul 30, 2015

Can you open two new issues with all the information you have on them?

@kingosticks
Member

I shall do so when I return from holiday next week.
On 30 Jul 2015 11:21, "Stein Magnus Jodal" notifications@github.com wrote:

Can you open two new issues with all the information you have on them?


Reply to this email directly or view it on GitHub
#165 (comment).

@jodal jodal locked and limited conversation to collaborators Nov 9, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.