matiasdelellis / libmpris2client

Library to control mpris2 compatible players
0 stars 3 forks source link

Segfault when used with deadbeef-mpris2-plugin #1

Closed Serranya closed 9 years ago

Serranya commented 10 years ago

I am the developer of the deadbeef-mpris2-plugin.

I have a strange problem when i use the xfce4-soundmenu-plugin with the DeaDBeeF plugin. A soon as i try to search for players, both the soundmenu plugin and Deadbeef crash.

dmesg shows me:

segfault at 8 ip 00007f2fb9a568d8 sp 00007fffd9300890 error 4 in libmpris2client.so.0.0.0[7f2fb9a53000+7000]

I tried debugging my plugin with gdb but that freezes my entire pc as soon as the crash occurs. Unfortunaly i dont have much c experience. Im not sure where the bug is. My plugin, libmpris2client, soundmenu plugin or even glibc.

Maybe you can test the setup on your machine.

I am using DeaDBeeF 0.6.2

matiasdelellis commented 10 years ago

Hi, mpris2-status-icon also crash?

Is much easier to debug with it.

Serranya commented 10 years ago

No crash. It works fine

matiasdelellis commented 10 years ago

Ohh.. Ok.. What versions you are using? Last release? Or git? (Of xfce4-soundmenu-plugin and also libmpris2control) Compiled by you? or package?

Serranya commented 10 years ago

Im Running xfce4-soundmenu-plugin v0.7.0, libmpris2client v0.1.0 and glibc 2.20 I compiled both xfce4-soundmenu-plugin and libmpris2client myself.

I dont think i have libmpris2control installed.

matiasdelellis commented 10 years ago

I dont think i have libmpris2control installed.

Not worries!. I mistook the name to my own product !!!. haha. :sweat_smile:

I compiled both xfce4-soundmenu-plugin and libmpris2client myself.

Ok. Can recompile libmpris2client with this pach? https://github.com/matiasdelellis/libmpris2client/commit/09325c3f55f37b962e31e5f7514610fcaed4c29f It should not change much, but it's something to try.

Change the code directly by hand, compile, install and restart xfce4-panel..

The way to debug the plugin is.

PANEL_DEBUG=gdb xfce4-panel

But this is useful when the plugin crash. Not when it freezes. See: http://docs.xfce.org/xfce/xfce4-panel/debugging

Serranya commented 10 years ago

sadly still crashes with

segfault at 8 ip 00007f51a92b3988 sp 00007fffb1886f80 error 4 in libmpris2client.so.0.0.0[7f51a92b0000+7000]

The last thing libmpris2client sends is

method call sender=:1.241 -> dest=org.mpris.MediaPlayer2.DeaDBeeF serial=22 path=/org/mpris/MediaPlayer2; interface=org.freedesktop.DBus.Properties; member=Set
   string "org.mpris.MediaPlayer2.Player"
   string "LoopStatus"
   variant       string "Playlist"

then DeaDBeeF and xfce4-soundmenu-plugin crash at the same time with the segfault i posted above.

matiasdelellis commented 10 years ago

Trying to understand what you printed seems that xfce4-soundmenu-plugin try set the property "LoopStatus" to "Playlist."

DeaDBeef mpris support it?? Test on a terminal

dbus-send --print-reply --session --type=method_call --dest=org.mpris.MediaPlayer2.DeaDBeeF /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Set string:org.mpris.MediaPlayer2.Player string:LoopStatus variant:string:None

matiasdelellis commented 10 years ago

I could compile your plugin and try the last command So,

[matias@localhost deadbeef-mpris2-plugin]$ gdb deadbeef 
GNU gdb (GDB) Fedora 7.7.1-21.fc20
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from deadbeef...Reading symbols from /usr/lib/debug/usr/bin/deadbeef.debug...done.
done.
(gdb) run
Starting program: /usr/bin/deadbeef 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
starting deadbeef 0.6.2
server_start
searching for GUI plugins in /home/matias/.local/lib64/deadbeef
searching for GUI plugins in /home/matias/.local/lib/deadbeef
searching for GUI plugins in /usr/lib64/deadbeef
plug_load_all: scandir found 48 files
found gui plugin ddb_gui_GTK3.so
added GTK3 gui plugin
load gui plugin
checking GUI plugin: GTK3
selected GUI plugin not found or failed to load, trying to find another GUI plugin
plugin not found or failed to load
plugin not found or failed to load
loading plugin /usr/lib64/deadbeef/ddb_gui_GTK3.so
gobject.pyc: gdb was not built with custom backtrace support, disabling.
Missing separate debuginfo for /lib64/libgraphite2.so.3
Try: yum --enablerepo='*debug*' install /usr/lib/debug/.build-id/90/82e46860379c3dff9004eb8c9834e50afbb528.debug
loading plugins from /home/matias/.local/lib64/deadbeef
loading plugins from /home/matias/.local/lib/deadbeef
loading plugins from /usr/lib64/deadbeef
plug_load_all: scandir found 48 files
loading plugin /usr/lib64/deadbeef/aac.so
loading plugin /usr/lib64/deadbeef/adplug.so
loading plugin /usr/lib64/deadbeef/alac.so
loading plugin /usr/lib64/deadbeef/alsa.so
loading plugin /usr/lib64/deadbeef/artwork.so
loading plugin /usr/lib64/deadbeef/cdda.so
loading plugin /usr/lib64/deadbeef/converter.so
loading plugin /usr/lib64/deadbeef/converter_gtk3.so
loading plugin /usr/lib64/deadbeef/dca.so
loading plugin /usr/lib64/deadbeef/ddb_ao.so
loading plugin /usr/lib64/deadbeef/ddb_dumb.so
loading plugin /usr/lib64/deadbeef/ddb_mono2stereo.so
loading plugin /usr/lib64/deadbeef/ddb_shn.so
loading plugin /usr/lib64/deadbeef/dsp_libsrc.so
loading plugin /usr/lib64/deadbeef/ffap.so
loading plugin /usr/lib64/deadbeef/ffmpeg.so
loading plugin /usr/lib64/deadbeef/flac.so
loading plugin /usr/lib64/deadbeef/gme.so
loading plugin /usr/lib64/deadbeef/hotkeys.so
loading plugin /usr/lib64/deadbeef/lastfm.so
loading plugin /usr/lib64/deadbeef/m3u.so
loading plugin /usr/lib64/deadbeef/mms.so
loading plugin /usr/lib64/deadbeef/mpgmad.so
loading plugin /usr/lib64/deadbeef/mpris.so
MPRIS Debug Info: Loading...
loading plugin /usr/lib64/deadbeef/musepack.so
loading plugin /usr/lib64/deadbeef/notify.so
loading plugin /usr/lib64/deadbeef/nullout.so
loading plugin /usr/lib64/deadbeef/oss.so
loading plugin /usr/lib64/deadbeef/pltbrowser_gtk3.so
loading plugin /usr/lib64/deadbeef/pulse.so
loading plugin /usr/lib64/deadbeef/shellexec.so
loading plugin /usr/lib64/deadbeef/shellexecui_gtk3.so
loading plugin /usr/lib64/deadbeef/sid.so
loading plugin /usr/lib64/deadbeef/sndfile.so
loading plugin /usr/lib64/deadbeef/supereq.so
loading plugin /usr/lib64/deadbeef/tta.so
loading plugin /usr/lib64/deadbeef/vfs_curl.so
loading plugin /usr/lib64/deadbeef/vfs_zip.so
loading plugin /usr/lib64/deadbeef/vorbis.so
loading plugin /usr/lib64/deadbeef/vtx.so
loading plugin /usr/lib64/deadbeef/wavpack.so
loading plugin /usr/lib64/deadbeef/wildmidi.so
loading plugin /usr/lib64/deadbeef/wma.so
[New Thread 0x7fffe97c4700 (LWP 24418)]
[New Thread 0x7fffe8fc3700 (LWP 24419)]
[New Thread 0x7fffe87c2700 (LWP 24420)]
[New Thread 0x7fffe7fc1700 (LWP 24421)]
libWildMidi(WM_BufferFile:640): ERROR Unable to stat /etc/timidity/freepats/freepats.cfg (No existe el fichero o el directorio)
selected output plugin: ALSA output plugin
INFO: loading playlist Predeterminado
INFO: from file /home/matias/.config/deadbeef/playlists/0.dbpl
[New Thread 0x7fffe77c0700 (LWP 24422)]
[New Thread 0x7fffe6fbf700 (LWP 24423)]
MPRIS Debug Info: Bus accquired
MPRIS Debug Info: name accquired: org.mpris.MediaPlayer2.DeaDBeeF
MPRIS Debug Info: Registering/org/mpris/MediaPlayer2object...
[New Thread 0x7fffe66ff700 (LWP 24424)]
[New Thread 0x7fffe5efe700 (LWP 24425)]
[New Thread 0x7fffe56fd700 (LWP 24426)]
gtkui plugin compiled for gtk version: 3.10.9

** (deadbeef:24414): WARNING **: Couldn't register with accessibility bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

(deadbeef:24414): Gtk-WARNING **: Theme parsing error: gtk-widgets-assets.css:17:22: Missing name of pseudo-class

(deadbeef:24414): Gtk-WARNING **: Theme parsing error: gtk-widgets-assets.css:23:28: Missing name of pseudo-class

(deadbeef:24414): Gtk-WARNING **: Theme parsing error: gtk-widgets-assets.css:29:34: Missing name of pseudo-class

(deadbeef:24414): Gtk-WARNING **: Theme parsing error: gtk-widgets-assets.css:65:22: Missing name of pseudo-class

(deadbeef:24414): Gtk-WARNING **: Theme parsing error: gtk-widgets-assets.css:71:28: Missing name of pseudo-class

(deadbeef:24414): Gtk-WARNING **: Theme parsing error: gtk-widgets-assets.css:77:34: Missing name of pseudo-class

(deadbeef:24414): Gtk-WARNING **: Theme parsing error: gtk-widgets-assets.css:101:40: Missing name of pseudo-class

(deadbeef:24414): Gtk-WARNING **: Theme parsing error: gtk-widgets-assets.css:105:46: Missing name of pseudo-class

(deadbeef:24414): Gtk-WARNING **: Theme parsing error: gtk-widgets-assets.css:109:52: Missing name of pseudo-class

(deadbeef:24414): Gtk-WARNING **: Theme parsing error: gtk-widgets-assets.css:128:40: Missing name of pseudo-class

(deadbeef:24414): Gtk-WARNING **: Theme parsing error: gtk-widgets-assets.css:132:46: Missing name of pseudo-class

(deadbeef:24414): Gtk-WARNING **: Theme parsing error: gtk-widgets-assets.css:136:52: Missing name of pseudo-class

(deadbeef:24414): Gtk-WARNING **: Theme parsing error: gtk-widgets-assets.css:144:80: Missing name of pseudo-class
connecting button tray signals
[New Thread 0x7fffcece5700 (LWP 24427)]
gtkui: found cover-art loader plugin
MPRIS Debug Info: Set property call on Player interface. sender: :1.277, propertyName: LoopStatus
MPRIS Debug Info: status is None
**
GLib-GIO:ERROR:gdbusconnection.c:4227:invoke_set_property_in_idle_cb: assertion failed: (error != NULL)

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffe7fc1700 (LWP 24421)]
0x0000003ce1a35877 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install alsa-lib-1.0.27.2-2.fc20.x86_64 at-spi2-atk-2.12.1-1.fc20.x86_64 at-spi2-core-2.12.0-2.fc20.x86_64 atk-2.12.0-2.fc20.x86_64 bzip2-libs-1.0.6-9.fc20.x86_64 cairo-1.13.1-0.1.git337ab1f.fc20.x86_64 cairo-gobject-1.13.1-0.1.git337ab1f.fc20.x86_64 celt-0.11.3-1.fc20.x86_64 cyrus-sasl-lib-2.1.26-14.fc20.x86_64 dbus-libs-1.6.12-9.fc20.x86_64 expat-2.1.0-7.fc20.x86_64 faad2-libs-2.7-5.fc20.x86_64 ffmpeg-libs-2.1.6-1.fc20.x86_64 flac-libs-1.3.0-3.fc20.x86_64 fontconfig-2.11.0-2.fc20.x86_64 freetype-2.5.0-5.fc20.x86_64 gdk-pixbuf2-2.30.8-1.fc20.x86_64 glib2-2.40.0-1.fc20.x86_64 glibc-2.18-16.fc20.x86_64 gmp-5.1.2-2.fc20.x86_64 gnutls-3.1.28-1.fc20.x86_64 gsm-1.0.13-10.fc20.x86_64 gtk3-3.12.2-2.fc20.x86_64 gvfs-1.20.3-1.fc20.x86_64 harfbuzz-0.9.27-1.fc20.x86_64 imlib2-1.4.5-10.fc20.x86_64 json-c-0.11-6.fc20.x86_64 keyutils-libs-1.5.9-1.fc20.x86_64 krb5-libs-1.11.5-11.fc20.x86_64 lame-libs-3.99.5-2.fc19.x86_64 libICE-1.0.8-6.fc20.x86_64 libSM-1.2.1-6.fc20.x86_64 libX11-1.6.1-1.fc20.x86_64 libXau-1.0.8-2.fc20.x86_64 libXcomposite-0.4.4-4.fc20.x86_64 libXcursor-1.1.14-2.fc20.x86_64 libXdamage-1.1.4-4.fc20.x86_64 libXext-1.3.2-2.fc20.x86_64 libXfixes-5.0.1-2.fc20.x86_64 libXi-1.7.4-1.fc20.x86_64 libXinerama-1.1.3-2.fc20.x86_64 libXrandr-1.4.1-2.fc20.x86_64 libXrender-0.9.8-2.fc20.x86_64 libXtst-1.2.2-2.fc20.x86_64 libXxf86vm-1.1.3-2.fc20.x86_64 libasyncns-0.8-6.fc20.x86_64 libattr-2.4.47-3.fc20.x86_64 libbluray-0.6.2-1.fc20.x86_64 libcap-2.22-7.fc20.x86_64 libcddb-1.3.2-12.fc20.x86_64 libcdio-0.90-3.fc20.x86_64 libcom_err-1.42.8-3.fc20.x86_64 libcurl-7.32.0-16.fc20.x86_64 libdrm-2.4.58-1.fc20.x86_64 libffi-3.0.13-5.fc20.x86_64 libgcc-4.8.3-7.fc20.x86_64 libgcrypt-1.5.3-2.fc20.x86_64 libgpg-error-1.12-1.fc20.x86_64 libidn-1.28-2.fc20.x86_64 libmad-0.15.1b-16.fc19.x86_64 libogg-1.3.0-6.fc20.x86_64 libpng-1.6.6-3.fc20.x86_64 libsamplerate-0.1.8-5.fc20.x86_64 libselinux-2.2.1-6.fc20.x86_64 libsndfile-1.0.25-8.fc20.x86_64 libssh2-1.4.3-10.fc20.x86_64 libstdc++-4.8.3-7.fc20.x86_64 libtasn1-3.8-2.fc20.x86_64 libtheora-1.1.1-9.fc20.x86_64 libuuid-2.24.2-2.fc20.x86_64 libva-1.2.1-3.fc20.x86_64 libvorbis-1.3.4-1.fc20.x86_64 libvpx-1.3.0-4.fc20.x86_64 libwayland-client-1.4.0-1.fc20.x86_64 libwayland-cursor-1.4.0-1.fc20.x86_64 libwayland-server-1.4.0-1.fc20.x86_64 libxcb-1.9.1-3.fc20.x86_64 libxkbcommon-0.4.3-2.fc20.x86_64 libxml2-2.9.1-3.fc20.x86_64 libzip-0.11.2-1.fc20.x86_64 mesa-libEGL-10.3.3-1.20141110.fc20.x86_64 mesa-libGL-10.3.3-1.20141110.fc20.x86_64 mesa-libgbm-10.3.3-1.20141110.fc20.x86_64 mesa-libglapi-10.3.3-1.20141110.fc20.x86_64 nettle-2.7.1-3.fc20.x86_64 nspr-4.10.7-1.fc20.x86_64 nss-3.17.2-1.fc20.x86_64 nss-softokn-freebl-3.17.2-1.fc20.x86_64 nss-util-3.17.2-1.fc20.x86_64 openjpeg-libs-1.5.1-13.fc20.x86_64 openldap-2.4.39-4.fc20.x86_64 openssl-libs-1.0.1e-40.fc20.x86_64 opus-1.1-1.fc20.x86_64 orc-0.4.22-2.fc20.x86_64 p11-kit-0.20.7-1.fc20.x86_64 pango-1.36.5-1.fc20.x86_64 pcre-8.33-7.fc20.x86_64 pixman-0.30.0-5.fc20.x86_64 pulseaudio-libs-5.0-7.fc20.x86_64 schroedinger-1.0.11-5.fc20.x86_64 speex-1.2-0.18.rc1.fc20.x86_64 systemd-libs-208-28.fc20.x86_64 tcp_wrappers-libs-7.6-76.fc20.x86_64 trousers-0.3.13-1.fc20.x86_64 wavpack-4.70.0-1.fc20.x86_64 x264-libs-0.138-2.20131030gitc628e3b.fc20.x86_64 xvidcore-1.3.2-5.fc20.x86_64 xz-libs-5.1.2-12alpha.fc20.x86_64 zlib-1.2.8-3.fc20.x86_64
(gdb) bt
#0  0x0000003ce1a35877 in raise () from /lib64/libc.so.6
#1  0x0000003ce1a36f68 in abort () from /lib64/libc.so.6
#2  0x0000003ce366eb45 in g_assertion_message () from /lib64/libglib-2.0.so.0
#3  0x0000003ce366ebda in g_assertion_message_expr () from /lib64/libglib-2.0.so.0
#4  0x00000036066cc686 in invoke_set_property_in_idle_cb () from /lib64/libgio-2.0.so.0
#5  0x0000003ce3649c3a in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
#6  0x0000003ce3649f88 in g_main_context_iterate.isra () from /lib64/libglib-2.0.so.0
#7  0x0000003ce364a25a in g_main_loop_run () from /lib64/libglib-2.0.so.0
#8  0x00007fffec51e3a9 in startServer (data=<optimized out>) at src/mprisServer.c:591
#9  0x0000003ce366f955 in g_thread_proxy () from /lib64/libglib-2.0.so.0
#10 0x0000003ce2607ee5 in start_thread () from /lib64/libpthread.so.0
#11 0x0000003ce1af4b8d in clone () from /lib64/libc.so.6
(gdb) 

And in another terminal send these command:

dbus-send --print-reply --session --type=method_call --dest=org.mpris.MediaPlayer2.DeaDBeeF /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Set string:org.mpris.MediaPlayer2.Player string:LoopStatus variant:string:None

And at that point is exactly when it breaks everything!. Supposedly in the line 591 of src/mprisServer.c

Serranya commented 10 years ago

Thank you very much for your help :) The Bug is indeed in my code.

matiasdelellis commented 10 years ago

Well, Seems that yes.. Why you use threads?. This only brings headaches!. :sweat:

Serranya commented 10 years ago

wow i am so stupid. i returned 0 in my method to handle the setting of properties. But i have to return TRUE

I think i have to use threads if i want to listen dbus messages in my plugin. If i would not spawn an extra thread i would block the entire execution of the player since my plugin does not get an own thread.

matiasdelellis commented 10 years ago

i returned 0 in my method to handle the setting of properties. But i have to return TRUE

Glad that you found it !. Then, upload the change to test it.. :wink:

I think i have to use threads if i want to listen dbus messages in my plugin. If i would not spawn an extra thread i would block the entire execution of the player since my plugin does not get an own thread.

Okay, but must be very careful.. And making a good use of signals should not have problems.. In pragha and parole do this, and never see problems.

Regards,

matiasdelellis commented 10 years ago

Another bug: https://github.com/Serranya/deadbeef-mpris2-plugin/blob/master/src/mprisServer.c#L173 Must check trackNumber!. No date.

Serranya commented 10 years ago

ahhhh and i have just released v1.2

Seems like v1.3 will follow very soon. Thank you for your contributions

EDIT: The wrong null checks are fixed.

matiasdelellis commented 10 years ago

Another.. Sorry.. hahaha.. ;) See https://github.com/Serranya/deadbeef-mpris2-plugin/blob/master/src/mprisServer.c#L414 And https://github.com/Serranya/deadbeef-mpris2-plugin/blob/master/src/mprisServer.c#L476

In both cases you are considering the shuffle backwards. :wink:

Serranya commented 10 years ago

Fixed :)

but i think i will wait a little bit before i release a new version. You probably find another bug very soon ;p

matiasdelellis commented 10 years ago

Hi, All signals emission, are doing wrong. So never updates the status of reproduction for example.

See: https://github.com/Serranya/deadbeef-mpris2-plugin/blob/master/src/mprisServer.c#L536 And use it as reference: https://github.com/pragha-music-player/pragha/blob/master/plugins/mpris2/pragha-mpris2-plugin.c#L1214

Serranya commented 10 years ago

I used the documentation from GNOME https://developer.gnome.org/gio/2.26/GDBusConnection.html See Example 2 EmitSignal.

I will look more into it after i slept a bit . Its 0:40 here and im to tired to code :D

matiasdelellis commented 10 years ago

You need see: Example 2. D-Bus server example but see on_timeout_cb() All signals of changes are made through "org.freedesktop.DBus.Properties.PropertiesChanged" that has a very specific format. See: http://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Property:LoopStatus :wink: