altdesktop / playerctl

🎧 mpris media player command-line controller for vlc, mpv, RhythmBox, web browsers, cmus, mpd, spotify and others.
GNU Lesser General Public License v3.0
2.43k stars 79 forks source link

SegFault when calling `playerctl.Player().play()` without any connected MPRIS server #12

Closed ntninja closed 9 years ago

ntninja commented 9 years ago
alexander@localhost:...$ gdb python3
...
(gdb) run
Starting program: /usr/bin/python3 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
Entering interactive mode...
>>> from gi.repository import Playerctl as playerctl
>>> p = playerctl.Player()
[New Thread 0x7ffff3e58700 (LWP 27204)]
>>> p.stop()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
GLib.Error: playerctl-player-error-quark: No players found (1)
>>> p.play()

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff3ee7c19 in org_mpris_media_player2_player_get_playback_status (object=0x0) at playerctl-generated.c:3021
3021      return ORG_MPRIS_MEDIA_PLAYER2_PLAYER_GET_IFACE (object)->get_playback_status (object);
(gdb) bt full
#0  0x00007ffff3ee7c19 in org_mpris_media_player2_player_get_playback_status (object=0x0) at playerctl-generated.c:3021
No locals.
#1  0x00007ffff3ee3483 in playerctl_player_play (self=0xc73350, err=0x7fffffffd750) at playerctl-player.c:532
        tmp_error = 0x0
        status = <optimized out>
        __func__ = "playerctl_player_play"
#2  0x00007ffff50bfdc0 in ffi_call_unix64 () from /usr/lib/x86_64-linux-gnu/libffi.so.6
No symbol table info available.
#3  0x00007ffff50bf828 in ffi_call () from /usr/lib/x86_64-linux-gnu/libffi.so.6
No symbol table info available.
#4  0x00007ffff5c84af4 in ?? () from /usr/lib/python3/dist-packages/gi/_gi.cpython-34m-x86_64-linux-gnu.so
No symbol table info available.
#5  0x00007ffff5c863f8 in ?? () from /usr/lib/python3/dist-packages/gi/_gi.cpython-34m-x86_64-linux-gnu.so
No symbol table info available.
#6  0x00007ffff5c7a5ae in ?? () from /usr/lib/python3/dist-packages/gi/_gi.cpython-34m-x86_64-linux-gnu.so
No symbol table info available.
#7  0x00000000004f2249 in PyEval_EvalFrameEx ()
No symbol table info available.
#8  0x00000000004ec9fc in PyEval_EvalCodeEx ()
No symbol table info available.
#9  0x0000000000581115 in ?? ()
No symbol table info available.
#10 0x000000000046021b in PyRun_InteractiveOneObject ()
No symbol table info available.
#11 0x000000000045fa36 in PyRun_InteractiveLoopFlags ()
No symbol table info available.
#12 0x000000000045bd6c in ?? ()
No symbol table info available.
#13 0x000000000041e233 in ?? ()
No symbol table info available.
#14 0x00000000004ca8ef in main ()
No symbol table info available.

As you can see from the log calling playerctl.Player().stop() produces the expected result (an exception), but playerctl.Player().play() causes a segmentation fault.

ntninja commented 9 years ago

Other observations:

acrisci commented 9 years ago

I can confirm this.

Error handling needs some improvements.

acrisci commented 9 years ago

I made some changes that should fix all these issues. Test it out and let me know if there are any more problems.

I want to make some changes to how the library handles a player that cannot connect when no bus name is given. Right now, the object is useless when it can't connect.

I think it should try to reconnect to the first player it can find whenever it can't find a player and use that player for the life of the object.

Another way to go would be to call the method on every player it can find, but that might cause problems, and won't work at all for retrieving metadata.

What do you think it should do?